Metrics
Query your metrics with PromQL, for one Managed Kubernetes cluster or across your whole organization. Results are in the Prometheus result format.
Permission: metrics read
Needs an Application Principal with metrics read access.
What you can query
| Scope | Includes | Operations |
|---|---|---|
| Your organization | Metrics that aren't tied to one cluster: your shared storage (IOPS, throughput, latency, capacity, quota use) and your nodes' hardware (GPU temperature and power, health, memory errors) | POST /v1/query, POST /v1/query_range |
| One cluster | That cluster's nodes (CPU, memory, disk, network), Kubernetes objects (pods, deployments, jobs, restarts), and GPUs (utilization, memory, temperature, power). The cluster bound is applied for you, so a query never sees another cluster's series. | POST /v1/clusters/{cluster_id}/query, POST /v1/clusters/{cluster_id}/query_range |
The metrics catalog lists every metric with its unit, labels, and sample interval. Which metrics exist depends on what runs in your fleets. To list the metric names available to you, count series by name:
Python SDK
import vpcloud_client
from vpcloud_client.models.query_request import QueryRequest
from vpcloud_client.results import decode_result
configuration = vpcloud_client.Configuration()
with vpcloud_client.ApiClient(configuration) as api_client:
metrics = vpcloud_client.MetricsApi(api_client)
response = metrics.query_org_metrics(QueryRequest(query='count by (__name__) ({__name__=~".+"})'))
print(sorted(series.labels["__name__"] for series in decode_result(response).series()))REST API
curl -X POST "$OBS_URL/v1/query" -H "Authorization: Bearer $OBS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"query": "count by (__name__) ({__name__=~\".+\"})"}'For one cluster, use the cluster operation with the same query. Common starting points:
| To see | Query |
|---|---|
| GPU utilization per node | avg by (Hostname) (DCGM_FI_DEV_GPU_UTIL) |
| GPU memory used | sum by (Hostname) (DCGM_FI_DEV_FB_USED) |
| Pods that aren't running | sum by (namespace, phase) (kube_pod_status_phase{phase!="Running"}) |
| Container restarts in the last hour | sum by (namespace, pod) (increase(kube_pod_container_status_restarts_total[1h])) |
| Node CPU use | 1 - avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) |
| Storage IOPS (organization) | sum by (__name__) ({__name__=~".*_iops.*"}) |
Instant queries
Evaluates a query at one point in time, now unless you set time.
Python SDK
with vpcloud_client.ApiClient(configuration) as api_client:
metrics = vpcloud_client.MetricsApi(api_client)
response = metrics.query_metrics(CLUSTER_ID, QueryRequest(query="avg by (Hostname) (DCGM_FI_DEV_GPU_UTIL)"))
for series in decode_result(response).series():
print(series.labels, series.samples[0].value)REST API
curl -X POST "$OBS_URL/v1/clusters/$CLUSTER_ID/query" -H "Authorization: Bearer $OBS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"query": "avg by (Hostname) (DCGM_FI_DEV_GPU_UTIL)"}'{
"result": {
"resultType": "vector",
"resultJson": "W3sibWV0cmljIjp7Ikhvc3RuYW1lIjoibm9kZS0xIn0sInZhbHVlIjpbMTc2MjgzNTIwMCwiOTcuNSJdfV0="
}
}resultJson is the base64 of the Prometheus data.result array. Decode it with base64 -d, or let the SDK's decode_result do it.
Range queries
Evaluates a query at every step between start and end, for charts and trends.
Python SDK
import datetime
from vpcloud_client.models.query_range_request import QueryRangeRequest
end = datetime.datetime.now(datetime.timezone.utc)
with vpcloud_client.ApiClient(configuration) as api_client:
metrics = vpcloud_client.MetricsApi(api_client)
response = metrics.query_org_metrics_range(QueryRangeRequest(
query='sum by (__name__) ({__name__=~".*_iops.*"})',
start=end - datetime.timedelta(hours=1),
end=end,
step="60s",
))
for series in decode_result(response).series():
print(series.labels, [(sample.time, sample.value) for sample in series.samples])REST API
curl -X POST "$OBS_URL/v1/query_range" -H "Authorization: Bearer $OBS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"query": "sum by (__name__) ({__name__=~\".*_iops.*\"})",
"start": "2026-11-10T09:00:00Z", "end": "2026-11-10T10:00:00Z", "step": "60s"}'startandendare RFC 3339 timestamps.stepis a duration in seconds, such as"60s"or"300s"(5 minutes). Other units such as"5m"aren't accepted.- A range with too many points for its step returns
400 Bad Request. Widen the step or narrow the range.
Stream metrics live
The Python SDK's watch re-evaluates your queries every step and yields each new result as it arrives, so you don't poll. It's for dashboards, autoscalers, and agents that react to your metrics.
from vpcloud_client.streaming import watch
queries = {"gpu_util": "avg by (Hostname) (DCGM_FI_DEV_GPU_UTIL)"}
with watch(configuration, queries, cluster_id=CLUSTER_ID, step="15s", reconnect=True) as stream:
for event in stream:
for series in event.series():
print(event.name, series.labels, [sample.value for sample in series.samples])| Option | What it does |
|---|---|
queries |
Up to 5: one query, a list (named q0, q1, ...), or a mapping of name to query. Each event's name says which query it answers. For more, group related metrics into one query with sum by (__name__) (...), or open a second stream. |
cluster_id |
One cluster. Leave it out to watch your whole organization. |
step |
How often the queries are evaluated, in seconds, for example "15s" or "300s". |
mode |
"samples" (the default) yields every new point. "changes" yields only the series that appear or disappear, in event.appeared and event.disappeared: for example, GPUs that cross an idle threshold. |
reconnect |
Reconnects a dropped stream and resumes where it left off, without missing or repeating points. |
cursor |
Resumes a stream you stopped, from the last event's cursor. |
awatchis the asyncio version, used withasync withandasync for.- Leaving the
withblock, or breaking out of the loop, closes the stream. - Errors raise
vpcloud_client.streaming.ConnectError, whosecodeis one of the names in the errors table. A cluster removed from your organization ends its stream withpermission_denied. - Streams end after a maximum lifetime. With
reconnect=Truethe SDK resumes them for you.
Limits
- Queries count against a per-organization limit. Over it, the API returns
429 Too Many Requests. Retry with backoff. - Organization-wide queries aren't available on every endpoint yet. Where they aren't, they return
501 Not Implemented. Contact support if you need them.
Was this page helpful?
Thanks for the feedback.