Observability / task

Query metrics

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

  • The URN of the project that holds the resource you want metrics for. The steps use it to find the resource’s URN.
  • Permission observability.metric.get on the resource. The built-in Owner and Viewer roles include it. See Roles.
  • An access token for the API. The examples get one from the origin CLI with origin id token. See Use the API.

Query the metrics

  1. Find the URN of the resource. Each command lists the resources of a project with their urn field:

    Terminal window
    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>
  2. 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.

  3. Choose the time window and the period. The query returns one data point per period, starting at from, so the number of data points per metric is (to - from) / periodSeconds + 1.

    • Use a periodSeconds of 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 from a multiple of the period (for example, a full hour) so data points line up with clock times.
  4. 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:

    {
    "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 query field reads:

    query Metrics($input: MetricQueryInput!) {
    observability {
    metrics(input: $input) {
    metricName
    resourceUrn
    unit
    dataPoints {
    timestamp
    value
    }
    }
    }
    }
  5. Send the request:

    Terminal window
    curl -s https://api.origincloud.eu/graphql \
    -H "$(origin id token --as-header --raw)" \
    -H "Content-Type: application/json" \
    --data @metrics-query.json
  6. Check the response. It contains one series per metric name you asked for, in the same order. For RATE on oc_compute_instance_cpu_seconds_total, a value of 0.5 means the instance used half a vCPU on average during that period.

    Example output (illustrative):

    {
    "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 RATE of a seconds counter is seconds per second.

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.

Note: Each successful query is billed as one request, however many metrics or data points it returns. A rejected query isn’t billed. See observability_api_request.

If the query returns an error, look up its extensions.code in Errors.

Origin Cloud — user documentation · last reviewed 2026-10-03 Legal notice Privacy policy