Kubernetes clusters
Get kubernetes cluster workload container usage
Returns observed usage percentiles, the current/recommended request, cost and the right-sizing recommendation for a single workload container, scoped to one resource dimension (cpu, memory or an accelerator measurement) and observation window, for the tenant selected by the X-CostGraph-Tenant-ID header. For gpu_utilization the request and limit are the whole accelerators the container holds.
GET
/
api
/
v1
/
tenant
/
clusters
/
{cluster_id}
/
workloads
/
{resource_id}
/
containers
/
{container_name}
/
usage
Get kubernetes cluster workload container usage
curl --request GET \
--url https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/workloads/{resource_id}/containers/{container_name}/usage \
--header 'Authorization: <api-key>' \
--header 'X-CostGraph-Tenant-ID: <x-costgraph-tenant-id>'import requests
url = "https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/workloads/{resource_id}/containers/{container_name}/usage"
headers = {
"X-CostGraph-Tenant-ID": "<x-costgraph-tenant-id>",
"Authorization": "<api-key>"
}
response = requests.get(url, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'X-CostGraph-Tenant-ID': '<x-costgraph-tenant-id>', Authorization: '<api-key>'}
};
fetch('https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/workloads/{resource_id}/containers/{container_name}/usage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/workloads/{resource_id}/containers/{container_name}/usage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"X-CostGraph-Tenant-ID: <x-costgraph-tenant-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/workloads/{resource_id}/containers/{container_name}/usage"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-CostGraph-Tenant-ID", "<x-costgraph-tenant-id>")
req.Header.Add("Authorization", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/workloads/{resource_id}/containers/{container_name}/usage")
.header("X-CostGraph-Tenant-ID", "<x-costgraph-tenant-id>")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/workloads/{resource_id}/containers/{container_name}/usage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-CostGraph-Tenant-ID"] = '<x-costgraph-tenant-id>'
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"message": "some message",
"status": "success",
"data": {
"container_name": "<string>",
"current_request": 123,
"limit": 123,
"metadata": {
"current_cost": 123,
"namespace": "<string>",
"nodes": [
"<string>"
],
"provider": "<string>",
"replicas": 123,
"spikiness_cv": 123,
"usage_type": "<string>",
"utilization_band": "<string>",
"volatility": "<string>",
"workload_kind": "<string>",
"recommended_cost": 123
},
"recommendation": {
"percent_change_in_request": 123,
"reasons": [
"<string>"
],
"recommendation": "<string>",
"estimated_savings_per_replica": 123
},
"resource": "<string>",
"stats": {
"id": "<string>",
"last": 123,
"max": 123,
"mean": 123,
"min": 123,
"p50": 123,
"p90": 123,
"p95": 123,
"p99": 123,
"std_dev": 123,
"tenant_id": "<string>"
},
"window": "<string>",
"recommended_request": 123
}
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}Authorizations
Enter "Bearer {token}"
Headers
Tenant ID
Path Parameters
Kubernetes cluster ID
Kubernetes workload resource ID
Container name
Query Parameters
Observation window. The gpu_sm_active, gpu_sm_occupancy, gpu_memory and gpu_memory_copy_utilization dimensions are recorded as a single latest observation, so they ignore this and answer with window latest.
Available options:
7d, 30d Resource dimension
Available options:
cpu, memory, gpu_utilization, gpu_sm_active, gpu_sm_occupancy, gpu_memory, gpu_memory_copy_utilization Was this page helpful?
⌘I
Get kubernetes cluster workload container usage
curl --request GET \
--url https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/workloads/{resource_id}/containers/{container_name}/usage \
--header 'Authorization: <api-key>' \
--header 'X-CostGraph-Tenant-ID: <x-costgraph-tenant-id>'import requests
url = "https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/workloads/{resource_id}/containers/{container_name}/usage"
headers = {
"X-CostGraph-Tenant-ID": "<x-costgraph-tenant-id>",
"Authorization": "<api-key>"
}
response = requests.get(url, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'X-CostGraph-Tenant-ID': '<x-costgraph-tenant-id>', Authorization: '<api-key>'}
};
fetch('https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/workloads/{resource_id}/containers/{container_name}/usage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/workloads/{resource_id}/containers/{container_name}/usage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"X-CostGraph-Tenant-ID: <x-costgraph-tenant-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/workloads/{resource_id}/containers/{container_name}/usage"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-CostGraph-Tenant-ID", "<x-costgraph-tenant-id>")
req.Header.Add("Authorization", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/workloads/{resource_id}/containers/{container_name}/usage")
.header("X-CostGraph-Tenant-ID", "<x-costgraph-tenant-id>")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/workloads/{resource_id}/containers/{container_name}/usage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-CostGraph-Tenant-ID"] = '<x-costgraph-tenant-id>'
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"message": "some message",
"status": "success",
"data": {
"container_name": "<string>",
"current_request": 123,
"limit": 123,
"metadata": {
"current_cost": 123,
"namespace": "<string>",
"nodes": [
"<string>"
],
"provider": "<string>",
"replicas": 123,
"spikiness_cv": 123,
"usage_type": "<string>",
"utilization_band": "<string>",
"volatility": "<string>",
"workload_kind": "<string>",
"recommended_cost": 123
},
"recommendation": {
"percent_change_in_request": 123,
"reasons": [
"<string>"
],
"recommendation": "<string>",
"estimated_savings_per_replica": 123
},
"resource": "<string>",
"stats": {
"id": "<string>",
"last": 123,
"max": 123,
"mean": 123,
"min": 123,
"p50": 123,
"p90": 123,
"p95": 123,
"p99": 123,
"std_dev": 123,
"tenant_id": "<string>"
},
"window": "<string>",
"recommended_request": 123
}
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}