Prometheus: Query Range
prometheus_query_rangeEvaluate PromQL expressions over a time range to detect spikes, trends, or when a change started, returning per-series min, max, avg, last statistics or step values.
Instructions
Evaluate a PromQL expression over a time range, for how something changed: a spike, a trend, when it started. Each series comes back with stats (min, max, avg, last) and, with view=values, one value per step on a shared grid given by start and step (null where there was no sample) — no per-point timestamps. The step is picked for about 60 points unless given. Many series are expensive: aggregate in the query (sum by), or use view=stats with sort=max to find the outliers first.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| end | No | Range end: now, now-1h, -30m, an RFC3339 timestamp (2026-01-31T12:00:00Z) or unix seconds. Defaults to now. | |
| sort | No | Order of series, applied before `limit` cuts: labels keeps Prometheus's order; max/avg/last rank highest first, so a cut keeps the biggest. | labels |
| step | No | Resolution, as a duration (30s, 5m, 1h) or seconds. Defaults to a round step giving about 60 points. Each series costs one value per step. | |
| view | No | values: stats plus the value at every step. stats: min/max/avg/last only, about a tenth of the size — use it to survey many series before plotting a few. | values |
| limit | No | Maximum series to return (1-500). Defaults to 20. | |
| query | Yes | A PromQL expression, e.g. `sum by (namespace) (rate(http_requests_total{status=~"5.."}[5m]))`. Aggregate inside the expression (sum by, topk, count) rather than fetching raw series and reading them: Prometheus does the arithmetic exactly and the answer is a fraction of the size. | |
| start | No | Range start: now, now-1h, -30m, an RFC3339 timestamp (2026-01-31T12:00:00Z) or unix seconds. Defaults to now-1h. | |
| precision | No | Significant digits to round fractional values to (whole numbers are never rounded). Defaults to 4; 0 returns the exact value. Raise it only when comparing values that differ past the fourth digit. |