Skip to main content

Timeseries queries

Time-bucketed model metrics over a window. Every timeseries query must include interval (or the deprecated intervalInSeconds). Buckets are expressed as <positive integer> <unit> strings like "5 minute", "1 hour", or "1 day". Each example below posts JSON to:
POST https://{your_control_plane_url}/api/svc/v1/llm-gateway/metrics/query
with Authorization: Bearer <your_api_key> and Content-Type: application/json. To keep the snippets short, only the JSON body is shown; the wrapper is identical to the Overview Quick Start.
By default, model metrics include both models and virtual models. The examples below pin the model side with {"fieldName": "virtualModelName", "operator": "IS_NULL", "value": true}. Flip the value to false (and swap groupBy: ["modelName"] for groupBy: ["virtualModel"]) for virtual-model-only series.
Hourly request counts:
json={
    "startTs": "2026-04-21T00:00:00.000Z",
    "endTs": "2026-04-22T00:00:00.000Z",
    "datasource": "modelMetrics",
    "type": "timeseries",
    "interval": "1 hour",
    "aggregations": [
        {"type": "count", "column": "modelName"}
    ],
    "filters": [
        {"fieldName": "virtualModelName", "operator": "IS_NULL", "value": true}
    ]
}
Fine-grained traffic with 5-minute buckets:
json={
    "startTs": "2026-04-21T00:00:00.000Z",
    "endTs": "2026-04-21T06:00:00.000Z",
    "datasource": "modelMetrics",
    "type": "timeseries",
    "interval": "5 minute",
    "aggregations": [
        {"type": "count", "column": "modelName"}
    ],
    "filters": [
        {"fieldName": "virtualModelName", "operator": "IS_NULL", "value": true}
    ]
}
Hourly counts grouped by model:
json={
    "startTs": "2026-04-21T00:00:00.000Z",
    "endTs": "2026-04-22T00:00:00.000Z",
    "datasource": "modelMetrics",
    "type": "timeseries",
    "interval": "1 hour",
    "aggregations": [
        {"type": "count", "column": "modelName"}
    ],
    "groupBy": ["modelName"],
    "filters": [
        {"fieldName": "virtualModelName", "operator": "IS_NULL", "value": true}
    ]
}
Track p99 latency regressions per model:
json={
    "startTs": "2026-04-21T00:00:00.000Z",
    "endTs": "2026-04-22T00:00:00.000Z",
    "datasource": "modelMetrics",
    "type": "timeseries",
    "interval": "1 hour",
    "aggregations": [
        {"type": "p99", "column": "latencyMs"}
    ],
    "groupBy": ["modelName"],
    "filters": [
        {"fieldName": "virtualModelName", "operator": "IS_NULL", "value": true}
    ]
}
Track per-team adoption over time:
json={
    "startTs": "2026-04-21T00:00:00.000Z",
    "endTs": "2026-04-22T00:00:00.000Z",
    "datasource": "modelMetrics",
    "type": "timeseries",
    "interval": "1 hour",
    "aggregations": [
        {"type": "count", "column": "team"}
    ],
    "groupBy": ["team"],
    "filters": [
        {"fieldName": "virtualModelName", "operator": "IS_NULL", "value": true}
    ]
}
Restrict to specific models and a latency threshold:
json={
    "startTs": "2026-04-21T00:00:00.000Z",
    "endTs": "2026-04-22T00:00:00.000Z",
    "datasource": "modelMetrics",
    "type": "timeseries",
    "interval": "1 hour",
    "aggregations": [
        {"type": "count", "column": "modelName"}
    ],
    "groupBy": ["modelName"],
    "filters": [
        {"fieldName": "virtualModelName", "operator": "IS_NULL", "value": true},
        {"fieldName": "modelName", "operator": "IN", "value": ["gpt-4", "gpt-3.5-turbo"]},
        {"fieldName": "latencyMs", "operator": "GREATER_THAN", "value": 500}
    ]
}
Cost burn-down per model over time:
json={
    "startTs": "2026-04-21T00:00:00.000Z",
    "endTs": "2026-04-22T00:00:00.000Z",
    "datasource": "modelMetrics",
    "type": "timeseries",
    "interval": "1 hour",
    "aggregations": [
        {"type": "sum", "column": "costInUSD"}
    ],
    "groupBy": ["modelName"],
    "filters": [
        {"fieldName": "virtualModelName", "operator": "IS_NULL", "value": true}
    ]
}
Group hourly counts by a custom metadata key:
json={
    "startTs": "2026-04-21T00:00:00.000Z",
    "endTs": "2026-04-22T00:00:00.000Z",
    "datasource": "modelMetrics",
    "type": "timeseries",
    "interval": "1 hour",
    "aggregations": [
        {"type": "count", "column": "modelName"}
    ],
    "groupBy": ["metadata.environment"],
    "filters": [
        {"fieldName": "virtualModelName", "operator": "IS_NULL", "value": true}
    ]
}
Daily traffic across a 7-day window:
json={
    "startTs": "2026-04-14T00:00:00.000Z",
    "endTs": "2026-04-21T00:00:00.000Z",
    "datasource": "modelMetrics",
    "type": "timeseries",
    "interval": "1 day",
    "aggregations": [
        {"type": "count", "column": "modelName"}
    ],
    "filters": [
        {"fieldName": "virtualModelName", "operator": "IS_NULL", "value": true}
    ]
}
Filters + groupBy + metadata together:
json={
    "startTs": "2026-04-21T00:00:00.000Z",
    "endTs": "2026-04-22T00:00:00.000Z",
    "datasource": "modelMetrics",
    "type": "timeseries",
    "interval": "1 hour",
    "aggregations": [
        {"type": "count", "column": "modelName"}
    ],
    "groupBy": ["modelName"],
    "filters": [
        {"fieldName": "virtualModelName", "operator": "IS_NULL", "value": true},
        {"fieldName": "modelName", "operator": "IN", "value": ["gpt-4", "gpt-3.5-turbo"]},
        {"metadataKey": "environment", "operator": "IN", "value": ["production"]}
    ]
}