Use the observability.metrics query to get a series of data points for one compute instance, volume, or network interface. You choose the metrics, the time window, the length of each period, and whether each data point is a per-second rate or a total increase.
Before you begin
Query the metrics
-
Find the URN of the resource. Each command lists the resources of a project with their
urnfield:terminal origin compute list-instances --project-urn <project-urn> origin storage list-volumes --project-urn <project-urn> origin network list-network-interfaces --project-urn <project-urn> -
Pick the metric names for that resource type. An instance has
oc_compute_instance_cpu_seconds_total; a volume and a network interface each have two metrics. See Metrics reference. -
Use a
periodSecondsof at least 60. The platform collects a value every 30 seconds, and each data point needs two collected values inside its period; a shorter period often returns no data points. -
Keep the total number of data points, across all metrics in the query, at or below 11,000. For example, one metric over 7 days at a 300-second period is 2,017 data points.
-
Make
froma multiple of the period (for example, a full hour) so data points line up with clock times. -
Save the request as
metrics-query.json. This example asks for the CPU use of an instance as a per-second rate, in 5-minute periods, over 15 minutes:JSON { "query": "query Metrics($input: MetricQueryInput!) { observability { metrics(input: $input) { metricName resourceUrn unit dataPoints { timestamp value } } } }", "variables": { "input": { "resourceUrn": "<instance-urn>", "metricNames": ["oc_compute_instance_cpu_seconds_total"], "from": "2026-10-03T10:00:00Z", "to": "2026-10-03T10:15:00Z", "periodSeconds": 300, "statistic": "RATE" } } }Formatted, the GraphQL query in the
queryfield reads:GraphQL query Metrics($input: MetricQueryInput!) { observability { metrics(input: $input) { metricName resourceUrn unit dataPoints { timestamp value } } } } -
Send the request:
terminal curl -s https://api.origincloud.eu/graphql \ -H "$(origin id token --as-header --raw)" \ -H "Content-Type: application/json" \ --data @metrics-query.json -
Check the response. It contains one series per metric name you asked for, in the same order. For
RATEonoc_compute_instance_cpu_seconds_total, a value of0.5means the instance used half a vCPU on average during that period. Example output (illustrative):JSON { "data": { "observability": { "metrics": [ { "metricName": "oc_compute_instance_cpu_seconds_total", "resourceUrn": "<instance-urn>", "unit": "seconds", "dataPoints": [ { "timestamp": "2026-10-03T10:00:00+00:00", "value": 0.12 }, { "timestamp": "2026-10-03T10:05:00+00:00", "value": 0.48 }, { "timestamp": "2026-10-03T10:10:00+00:00", "value": 1.73 }, { "timestamp": "2026-10-03T10:15:00+00:00", "value": 0.51 } ] } ] } } }Each data point covers the period that ends at its timestamp. The unit is the unit of the counter, so a
RATEof a seconds counter is seconds per second.Both ends of the window are included: data points fall on
from, everyperiodSecondsafter it, andto, which is why a 15-minute window at 300 seconds returns four points. The first point, atfrom, covers the period beforefrom(here 09:55 to 10:00). To cover only the window itself, setfromone period later.
A series with an empty dataPoints list means the platform has no values for that resource and metric in the window. Common reasons are an instance that was stopped, a volume or network interface that wasn’t attached to a running instance, a metric name that belongs to another resource type, or a window older than the 90 days the platform keeps metrics.
If the query returns an error, look up its extensions.code in Errors.
Related
- Metrics reference – every metric, argument, limit, and error.
- What is Origin Cloud Observability? – how counters,
RATE, andINCREASEwork. - Use the GraphQL API – authenticating against the GraphQL API.