topk
PromQL aggregation operators that keep the k series with the largest, or smallest, values.
In more detail
topk(3, x) returns the three highest series of x at each evaluation step, keeping their labels. Combined with by, it picks the largest series within each group, and a graph of it can switch between series over time.
Example
topk(3, rate(http_requests_total[5m]))Related terms
- aggregation operator — A PromQL operator such as sum, count or max that combines many series into fewer, optionally grouped by chosen labels.
- PromQL — The query language of Prometheus, used to select time series and calculate rates, sums and percentiles from them.
Taught in
- Fifteen Requests Nobody Saw: Aggregating Over Time — Prometheus Certified Associate (PCA) Exam Prep
- Fifteen Lines And No Answer: Aggregating Over Labels — Prometheus Certified Associate (PCA) Exam Prep
- PromQL Sprint: Ten Queries At Minute Twenty Two — Prometheus Certified Associate (PCA) Exam Prep