Virtual machines
Get virtual machine container metrics
Returns time-series observability metrics for a container on the selected virtual machine
GET
/
api
/
v1
/
tenant
/
virtual-machines
/
{id}
/
containers
/
{container_id}
/
metrics
Get virtual machine container metrics
curl --request GET \
--url https://api.costgraph.ai/api/v1/tenant/virtual-machines/{id}/containers/{container_id}/metrics \
--header 'Authorization: <api-key>' \
--header 'X-CostGraph-Tenant-ID: <x-costgraph-tenant-id>'import requests
url = "https://api.costgraph.ai/api/v1/tenant/virtual-machines/{id}/containers/{container_id}/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/virtual-machines/{id}/containers/{container_id}/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/virtual-machines/{id}/containers/{container_id}/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/virtual-machines/{id}/containers/{container_id}/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/virtual-machines/{id}/containers/{container_id}/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/virtual-machines/{id}/containers/{container_id}/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": {
"end": "<string>",
"start": "<string>",
"step_seconds": 123,
"cpu_throttled_periods": [
{
"t": 123,
"v": 123
}
],
"cpu_usage_cores": [
{
"t": 123,
"v": 123
}
],
"filesystem_read_throughput": [
{
"t": 123,
"v": 123
}
],
"filesystem_usage_bytes": [
{
"t": 123,
"v": 123
}
],
"filesystem_write_throughput": [
{
"t": 123,
"v": 123
}
],
"memory_usage_bytes": [
{
"t": 123,
"v": 123
}
],
"memory_working_set_bytes": [
{
"t": 123,
"v": 123
}
],
"network_receive": [
{
"t": 123,
"v": 123
}
],
"network_transmit": [
{
"t": 123,
"v": 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
Query Parameters
Time window (e.g. 1h, 6h, 24h, 7d). Default 1h
Resolution step (e.g. 30s, 1m, 5m)
Metric groups to fetch (comma-separated): all,cpu,memory,network,disk. Default all
Was this page helpful?
⌘I
Get virtual machine container metrics
curl --request GET \
--url https://api.costgraph.ai/api/v1/tenant/virtual-machines/{id}/containers/{container_id}/metrics \
--header 'Authorization: <api-key>' \
--header 'X-CostGraph-Tenant-ID: <x-costgraph-tenant-id>'import requests
url = "https://api.costgraph.ai/api/v1/tenant/virtual-machines/{id}/containers/{container_id}/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/virtual-machines/{id}/containers/{container_id}/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/virtual-machines/{id}/containers/{container_id}/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/virtual-machines/{id}/containers/{container_id}/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/virtual-machines/{id}/containers/{container_id}/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/virtual-machines/{id}/containers/{container_id}/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": {
"end": "<string>",
"start": "<string>",
"step_seconds": 123,
"cpu_throttled_periods": [
{
"t": 123,
"v": 123
}
],
"cpu_usage_cores": [
{
"t": 123,
"v": 123
}
],
"filesystem_read_throughput": [
{
"t": 123,
"v": 123
}
],
"filesystem_usage_bytes": [
{
"t": 123,
"v": 123
}
],
"filesystem_write_throughput": [
{
"t": 123,
"v": 123
}
],
"memory_usage_bytes": [
{
"t": 123,
"v": 123
}
],
"memory_working_set_bytes": [
{
"t": 123,
"v": 123
}
],
"network_receive": [
{
"t": 123,
"v": 123
}
],
"network_transmit": [
{
"t": 123,
"v": 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"
}