Get kubernetes cluster workload container metrics
Returns time-series for a single workload container - CPU usage, memory usage, CPU throttling as a percent of scheduling periods, PVC disk read, write and aggregated throughput, PVC disk read, write and aggregated IOPS, and the health series (out-of-memory kills, restarts, memory used of limit, CPU and memory contention, evictions, stuck replicas, not ready, failed probes) - pooled across the workload’s replicas, a health summary over the same range (status, findings and per-signal totals and peaks; null when no metrics store is configured, status unknown when the cluster reports nothing for the container), and, where the accelerator exporter attributes a device to this container, the device’s utilisation, memory and power, how many devices the container holds, and whether it holds them exclusively, for the tenant selected by the X-CostGraph-Tenant-ID header
curl --request GET \
--url https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/workloads/{resource_id}/containers/{container_name}/metrics \
--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}/metrics"
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}/metrics', 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}/metrics",
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}/metrics"
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}/metrics")
.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}/metrics")
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": {
"api_version": "<string>",
"container_name": "<string>",
"cpu_contention": [
{
"t": 123,
"v": 123
}
],
"cpu_throttle": [
{
"t": 123,
"v": 123
}
],
"cpu_usage": [
{
"t": 123,
"v": 123
}
],
"end": "<string>",
"evictions": [
{
"t": 123,
"v": 123
}
],
"gpu_availability": {},
"gpu_memory_used_mib": [
{
"t": 123,
"v": 123
}
],
"gpu_memory_utilization": [
{
"t": 123,
"v": 123
}
],
"gpu_power_utilization": [
{
"t": 123,
"v": 123
}
],
"gpu_power_watts": [
{
"t": 123,
"v": 123
}
],
"gpu_utilization": [
{
"t": 123,
"v": 123
}
],
"iops": [
{
"t": 123,
"v": 123
}
],
"memory_contention": [
{
"t": 123,
"v": 123
}
],
"memory_usage": [
{
"t": 123,
"v": 123
}
],
"memory_used_of_limit": [
{
"t": 123,
"v": 123
}
],
"namespace": "<string>",
"not_ready": [
{
"t": 123,
"v": 123
}
],
"out_of_memory_kills": [
{
"t": 123,
"v": 123
}
],
"probe_failures": [
{
"t": 123,
"v": 123
}
],
"read_iops": [
{
"t": 123,
"v": 123
}
],
"read_throughput": [
{
"t": 123,
"v": 123
}
],
"resource_id": "<string>",
"restarts": [
{
"t": 123,
"v": 123
}
],
"start": "<string>",
"step_seconds": 123,
"stuck_replicas": [
{
"t": 123,
"v": 123
}
],
"throughput": [
{
"t": 123,
"v": 123
}
],
"workload_kind": "<string>",
"workload_name": "<string>",
"write_iops": [
{
"t": 123,
"v": 123
}
],
"write_throughput": [
{
"t": 123,
"v": 123
}
],
"gpu_device_exclusive": true,
"gpu_devices_held": 123,
"gpu_identity_source": "<string>",
"health": {
"contention_available": true,
"evictions": 123,
"findings": [
{
"message": "<string>",
"severity": "<string>",
"signal": "<string>"
}
],
"liveness_probe_failures": 123,
"memory_limit_set": true,
"not_ready_seconds": 123,
"out_of_memory_kills": 123,
"readiness_available": true,
"readiness_probe_failures": 123,
"restarts": 123,
"status": "<string>",
"stuck_seconds": 123,
"cpu_contention_peak_percent": 123,
"cpu_throttling_p95_percent": 123,
"cpu_throttling_peak_percent": 123,
"last_out_of_memory_kill_at": "<string>",
"last_restart_at": "<string>",
"last_restart_exit_code": 123,
"last_restart_reason": "<string>",
"memory_contention_peak_percent": 123,
"memory_used_of_limit_peak_percent": 123,
"not_ready_percent": 123,
"stuck_reason": "<string>"
},
"pods": [
{
"cpu_usage": [
{
"t": 123,
"v": 123
}
],
"memory_usage": [
{
"t": 123,
"v": 123
}
],
"pod": "<string>"
}
]
}
}{
"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"
}Path Parameters
Was this page helpful?
curl --request GET \
--url https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/workloads/{resource_id}/containers/{container_name}/metrics \
--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}/metrics"
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}/metrics', 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}/metrics",
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}/metrics"
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}/metrics")
.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}/metrics")
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": {
"api_version": "<string>",
"container_name": "<string>",
"cpu_contention": [
{
"t": 123,
"v": 123
}
],
"cpu_throttle": [
{
"t": 123,
"v": 123
}
],
"cpu_usage": [
{
"t": 123,
"v": 123
}
],
"end": "<string>",
"evictions": [
{
"t": 123,
"v": 123
}
],
"gpu_availability": {},
"gpu_memory_used_mib": [
{
"t": 123,
"v": 123
}
],
"gpu_memory_utilization": [
{
"t": 123,
"v": 123
}
],
"gpu_power_utilization": [
{
"t": 123,
"v": 123
}
],
"gpu_power_watts": [
{
"t": 123,
"v": 123
}
],
"gpu_utilization": [
{
"t": 123,
"v": 123
}
],
"iops": [
{
"t": 123,
"v": 123
}
],
"memory_contention": [
{
"t": 123,
"v": 123
}
],
"memory_usage": [
{
"t": 123,
"v": 123
}
],
"memory_used_of_limit": [
{
"t": 123,
"v": 123
}
],
"namespace": "<string>",
"not_ready": [
{
"t": 123,
"v": 123
}
],
"out_of_memory_kills": [
{
"t": 123,
"v": 123
}
],
"probe_failures": [
{
"t": 123,
"v": 123
}
],
"read_iops": [
{
"t": 123,
"v": 123
}
],
"read_throughput": [
{
"t": 123,
"v": 123
}
],
"resource_id": "<string>",
"restarts": [
{
"t": 123,
"v": 123
}
],
"start": "<string>",
"step_seconds": 123,
"stuck_replicas": [
{
"t": 123,
"v": 123
}
],
"throughput": [
{
"t": 123,
"v": 123
}
],
"workload_kind": "<string>",
"workload_name": "<string>",
"write_iops": [
{
"t": 123,
"v": 123
}
],
"write_throughput": [
{
"t": 123,
"v": 123
}
],
"gpu_device_exclusive": true,
"gpu_devices_held": 123,
"gpu_identity_source": "<string>",
"health": {
"contention_available": true,
"evictions": 123,
"findings": [
{
"message": "<string>",
"severity": "<string>",
"signal": "<string>"
}
],
"liveness_probe_failures": 123,
"memory_limit_set": true,
"not_ready_seconds": 123,
"out_of_memory_kills": 123,
"readiness_available": true,
"readiness_probe_failures": 123,
"restarts": 123,
"status": "<string>",
"stuck_seconds": 123,
"cpu_contention_peak_percent": 123,
"cpu_throttling_p95_percent": 123,
"cpu_throttling_peak_percent": 123,
"last_out_of_memory_kill_at": "<string>",
"last_restart_at": "<string>",
"last_restart_exit_code": 123,
"last_restart_reason": "<string>",
"memory_contention_peak_percent": 123,
"memory_used_of_limit_peak_percent": 123,
"not_ready_percent": 123,
"stuck_reason": "<string>"
},
"pods": [
{
"cpu_usage": [
{
"t": 123,
"v": 123
}
],
"memory_usage": [
{
"t": 123,
"v": 123
}
],
"pod": "<string>"
}
]
}
}{
"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"
}