http
POST /projects/{project_reference}/metrics/queryQuery project metrics. Requires project.metrics.read.
Parameters
| Name | In | Required | Description |
|---|---|---|---|
project_reference | path | Yes |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
metric | string | Yes | Prometheus metric name. Raw PromQL is not accepted. |
start | string | Start 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. | |
end | string | End time (RFC 3339). Defaults to now. | |
step | string | Prometheus query step, for example 60s. | |
aggregation | string | Aggregation to apply to the project-scoped metric selector. | |
labels | object | Optional 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
| Status | Description |
|---|---|
| 200 | Project-scoped Prometheus-compatible metric series. The result is never partial: a result over a limit returns 413. |
| 400 | Invalid metric query parameters, including a time range beyond retention |
| 401 | Unauthorized |
| 403 | Missing project.metrics.read capability |
| 404 | Project not found |
| 413 | The 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. |
| 429 | Rate limit exceeded |
| 500 | Server error |
| 502 | External metric provider error from the Prometheus-compatible read path |
| 503 | Metric service unavailable or Prometheus-compatible read path is not configured |