Query metrics

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

Query project metrics. Requires project.metrics.read.

Servers

JSON
[  {    "url": "https://api.veryfront.com"  }]

Authentication

JSON
[  {    "bearerAuth": []  },  {    "apiKeyAuth": []  }]
JSON
{  "bearerAuth": {    "type": "http",    "scheme": "bearer",    "bearerFormat": "JWT or API Key",    "description": "Use a JWT bearer token or a Veryfront API key in the `Authorization` header."  },  "apiKeyAuth": {    "type": "apiKey",    "in": "header",    "name": "X-API-Key",    "description": "Alternative API key header for `vf_<prefix>_<secret>` tokens."  }}

Parameters

NameLocationRequiredDescription
project_referencepathYes

Parameter contracts

JSON
[  {    "schema": {      "type": "string",      "description": "Project slug or UUID. The resolved project is used to scope all metric reads server-side."    },    "required": true,    "name": "project_reference",    "in": "path"  }]

Request body

JSON
{  "content": {    "application/json": {      "schema": {        "type": "object",        "properties": {          "metric": {            "type": "string",            "minLength": 1,            "maxLength": 200,            "description": "Prometheus metric name. Raw PromQL is not accepted."          },          "start": {            "type": "string",            "format": "date-time",            "description": "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": {            "type": "string",            "format": "date-time",            "description": "End time (RFC 3339). Defaults to now."          },          "step": {            "type": "string",            "minLength": 1,            "maxLength": 20,            "default": "60s",            "description": "Prometheus query step, for example 60s."          },          "aggregation": {            "type": "string",            "enum": [              "none",              "sum",              "avg",              "min",              "max",              "count"            ],            "default": "none",            "description": "Aggregation to apply to the project-scoped metric selector."          },          "labels": {            "type": "object",            "additionalProperties": {              "type": "string"            },            "description": "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."          }        },        "required": [          "metric"        ]      }    }  }}

Responses

200

Project-scoped Prometheus-compatible metric series. The result is never partial: a result over a limit returns 413.

JSON
{  "description": "Project-scoped Prometheus-compatible metric series. The result is never partial: a result over a limit returns 413.",  "content": {    "application/json": {      "schema": {        "type": "object",        "properties": {          "series": {            "type": "array",            "items": {              "type": "object",              "properties": {                "metric": {                  "type": "string"                },                "labels": {                  "type": "object",                  "additionalProperties": {                    "type": "string"                  }                },                "points": {                  "type": "array",                  "items": {                    "type": "object",                    "properties": {                      "timestamp": {                        "type": "string"                      },                      "value": {                        "type": "number"                      }                    },                    "required": [                      "timestamp",                      "value"                    ]                  }                }              },              "required": [                "metric",                "labels",                "points"              ]            }          },          "stats": {            "type": "object",            "properties": {              "query_time_ms": {                "type": "number"              }            },            "required": [              "query_time_ms"            ]          }        },        "required": [          "series",          "stats"        ]      }    }  }}

400

Invalid metric query parameters, including a time range beyond retention

JSON
{  "description": "Invalid metric query parameters, including a time range beyond retention",  "content": {    "application/problem+json": {      "schema": {        "$ref": "#/components/schemas/Problem"      }    }  }}

401

Unauthorized

JSON
{  "description": "Unauthorized",  "content": {    "application/problem+json": {      "schema": {        "$ref": "#/components/schemas/Problem"      }    }  }}

403

Missing project.metrics.read capability

JSON
{  "description": "Missing project.metrics.read capability",  "content": {    "application/problem+json": {      "schema": {        "$ref": "#/components/schemas/Problem"      }    }  }}

404

Project not found

JSON
{  "description": "Project not found",  "content": {    "application/problem+json": {      "schema": {        "$ref": "#/components/schemas/Problem"      }    }  }}

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.

JSON
{  "description": "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.",  "content": {    "application/problem+json": {      "schema": {        "$ref": "#/components/schemas/Problem"      }    }  }}

429

Rate limit exceeded

JSON
{  "description": "Rate limit exceeded",  "content": {    "application/problem+json": {      "schema": {        "$ref": "#/components/schemas/Problem"      }    }  }}

500

Server error

JSON
{  "description": "Server error",  "content": {    "application/problem+json": {      "schema": {        "$ref": "#/components/schemas/Problem"      }    }  }}

502

External metric provider error from the Prometheus-compatible read path

JSON
{  "description": "External metric provider error from the Prometheus-compatible read path",  "content": {    "application/problem+json": {      "schema": {        "$ref": "#/components/schemas/Problem"      }    }  }}

503

Metric service unavailable or Prometheus-compatible read path is not configured

JSON
{  "description": "Metric service unavailable or Prometheus-compatible read path is not configured",  "content": {    "application/problem+json": {      "schema": {        "$ref": "#/components/schemas/Problem"      }    }  }}

Referenced contracts

components/schemas/Problem

JSON
{  "type": "object",  "properties": {    "cause": {      "type": "string",      "enum": [        "schedule_concurrency_forbidden",        "schedule_fire_in_progress",        "schedule_run_limit_reached"      ],      "description": "Schedule admission refusal."    },    "idempotency": {      "type": "object",      "properties": {        "state": {          "type": "string",          "enum": [            "in_progress",            "payload_mismatch",            "outcome_unknown"          ]        },        "operation": {          "type": "string",          "minLength": 1        },        "retryable": {          "type": "boolean"        },        "retry_after_seconds": {          "type": [            "integer",            "null"          ],          "minimum": 0        },        "expires_at": {          "type": [            "string",            "null"          ]        },        "recovery": {          "type": "object",          "properties": {            "available": {              "type": "boolean"            },            "description": {              "type": "string"            },            "resource_url": {              "type": "string"            }          },          "required": [            "available",            "description"          ]        }      },      "required": [        "state",        "operation",        "retryable",        "retry_after_seconds",        "expires_at"      ],      "description": "Replay status, retry timing, and recovery lookup."    },    "type": {      "type": "string",      "description": "URI reference identifying the problem type",      "example": "https://api.veryfront.com/errors/validation-failed"    },    "title": {      "type": "string",      "description": "Short human-readable summary of the problem",      "example": "Validation Failed"    },    "status": {      "type": "integer",      "minimum": 100,      "maximum": 599,      "description": "HTTP status code",      "example": 400    },    "code": {      "type": "string",      "description": "Stable machine-readable error code",      "example": "RUN_INVALID_INPUT"    },    "detail": {      "type": "string",      "description": "Human-readable explanation specific to this occurrence",      "example": "The 'email' field must be a valid email address"    },    "instance": {      "type": "string",      "description": "URI reference identifying the specific occurrence",      "example": "/projects/my-project/members"    },    "slug": {      "type": "string",      "description": "Stable identifier for the problem type",      "example": "validation-failed"    },    "category": {      "type": "string",      "enum": [        "AUTH",        "RESOURCE",        "VALIDATION",        "DATABASE",        "SUBSCRIPTION",        "INTEGRATION",        "INTERNAL"      ],      "description": "API error category",      "example": "VALIDATION"    },    "suggestion": {      "type": "string",      "description": "Suggested action to resolve the problem",      "example": "Check the request body and query parameters against the API documentation."    },    "errors": {      "type": "array",      "items": {        "type": "object",        "properties": {          "field": {            "type": "string",            "description": "Field path that caused the error",            "example": "email"          },          "message": {            "type": "string",            "description": "Error message for this field",            "example": "Invalid email format"          },          "code": {            "type": "string",            "description": "Error code for this field",            "example": "INVALID_FORMAT"          }        },        "required": [          "field",          "message"        ]      },      "description": "Detailed field-level errors for validation failures"    }  },  "required": [    "type",    "title",    "status"  ]}

Operation contract

JSON
{  "operationId": "queryProjectMetrics",  "tags": [    "observability/Metrics/Metric series"  ],  "summary": "Query metrics",  "description": "Query project metrics. Requires project.metrics.read.",  "parameters": [    {      "schema": {        "type": "string",        "description": "Project slug or UUID. The resolved project is used to scope all metric reads server-side."      },      "required": true,      "name": "project_reference",      "in": "path"    }  ],  "requestBody": {    "content": {      "application/json": {        "schema": {          "type": "object",          "properties": {            "metric": {              "type": "string",              "minLength": 1,              "maxLength": 200,              "description": "Prometheus metric name. Raw PromQL is not accepted."            },            "start": {              "type": "string",              "format": "date-time",              "description": "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": {              "type": "string",              "format": "date-time",              "description": "End time (RFC 3339). Defaults to now."            },            "step": {              "type": "string",              "minLength": 1,              "maxLength": 20,              "default": "60s",              "description": "Prometheus query step, for example 60s."            },            "aggregation": {              "type": "string",              "enum": [                "none",                "sum",                "avg",                "min",                "max",                "count"              ],              "default": "none",              "description": "Aggregation to apply to the project-scoped metric selector."            },            "labels": {              "type": "object",              "additionalProperties": {                "type": "string"              },              "description": "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."            }          },          "required": [            "metric"          ]        }      }    }  },  "responses": {    "200": {      "description": "Project-scoped Prometheus-compatible metric series. The result is never partial: a result over a limit returns 413.",      "content": {        "application/json": {          "schema": {            "type": "object",            "properties": {              "series": {                "type": "array",                "items": {                  "type": "object",                  "properties": {                    "metric": {                      "type": "string"                    },                    "labels": {                      "type": "object",                      "additionalProperties": {                        "type": "string"                      }                    },                    "points": {                      "type": "array",                      "items": {                        "type": "object",                        "properties": {                          "timestamp": {                            "type": "string"                          },                          "value": {                            "type": "number"                          }                        },                        "required": [                          "timestamp",                          "value"                        ]                      }                    }                  },                  "required": [                    "metric",                    "labels",                    "points"                  ]                }              },              "stats": {                "type": "object",                "properties": {                  "query_time_ms": {                    "type": "number"                  }                },                "required": [                  "query_time_ms"                ]              }            },            "required": [              "series",              "stats"            ]          }        }      }    },    "400": {      "description": "Invalid metric query parameters, including a time range beyond retention",      "content": {        "application/problem+json": {          "schema": {            "$ref": "#/components/schemas/Problem"          }        }      }    },    "401": {      "description": "Unauthorized",      "content": {        "application/problem+json": {          "schema": {            "$ref": "#/components/schemas/Problem"          }        }      }    },    "403": {      "description": "Missing project.metrics.read capability",      "content": {        "application/problem+json": {          "schema": {            "$ref": "#/components/schemas/Problem"          }        }      }    },    "404": {      "description": "Project not found",      "content": {        "application/problem+json": {          "schema": {            "$ref": "#/components/schemas/Problem"          }        }      }    },    "413": {      "description": "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.",      "content": {        "application/problem+json": {          "schema": {            "$ref": "#/components/schemas/Problem"          }        }      }    },    "429": {      "description": "Rate limit exceeded",      "content": {        "application/problem+json": {          "schema": {            "$ref": "#/components/schemas/Problem"          }        }      }    },    "500": {      "description": "Server error",      "content": {        "application/problem+json": {          "schema": {            "$ref": "#/components/schemas/Problem"          }        }      }    },    "502": {      "description": "External metric provider error from the Prometheus-compatible read path",      "content": {        "application/problem+json": {          "schema": {            "$ref": "#/components/schemas/Problem"          }        }      }    },    "503": {      "description": "Metric service unavailable or Prometheus-compatible read path is not configured",      "content": {        "application/problem+json": {          "schema": {            "$ref": "#/components/schemas/Problem"          }        }      }    }  },  "x-documentation-source-tag": "Project metrics",  "x-canonical-documentation": {    "domain": "observability",    "resource": "Metrics",    "subgroup": "Metric series",    "name": "Query metrics",    "description": "Query project metrics. Requires project.metrics.read.",    "operationId": "queryProjectMetrics"  },  "x-mint": {    "href": "/cloud/rest/api-reference/observability-metrics-metric-series/query-metrics"  }}