Query metrics

http
POST /projects/{project_reference}/metrics/query

Query project metrics. Requires project.metrics.read.

Parameters

NameInRequiredDescription
project_referencepathYes

Request body

FieldTypeRequiredDescription
metricstringYesPrometheus metric name. Raw PromQL is not accepted.
startstringStart time (RFC 3339). Defaults to 1 hour ago. Metrics are kept for 395 days and one query spans at most 31 days; an older start or a wider range returns 400.
endstringEnd time (RFC 3339). Defaults to now.
stepstringPrometheus query step, for example 60s.
aggregationstringAggregation to apply to the project-scoped metric selector.
labelsobjectOptional allowlisted label filters such as environment, service_name or status_code. environment is the project environment on every metric: its name, matched case-insensitively, or preview for a branch. ai_gateway_* metrics carry it for calls made by a project run. Unknown, platform (deployment_environment) and project-scope labels are rejected.

Responses

StatusDescription
200Project-scoped Prometheus-compatible metric series. The result is never partial: a result over a limit returns 413.
400Invalid metric query parameters, including a time range beyond retention
401Unauthorized
403Missing project.metrics.read capability
404Project not found
413The result would not be complete: more than 100 series, a series with more than 11,000 points, or an upstream body over 8 MiB. Add a label filter, choose an aggregation, or use a coarser step or a shorter range.
429Rate limit exceeded
500Server error
502External metric provider error from the Prometheus-compatible read path
503Metric service unavailable or Prometheus-compatible read path is not configured