Skip to content

Commit e936e41

Browse files
authored
Merge pull request prometheus#16009 from charleskorn/topk-bottomk-sorting
docs: make sorting behaviour of `topk` and `bottomk` explicit
2 parents de23a96 + 2cfd402 commit e936e41

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

docs/querying/operators.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,14 @@ the input samples, including the original labels, are returned in the result
319319
vector. `by` and `without` are only used to bucket the input vector. Similar to
320320
`min` and `max`, they only operate on float samples, considering `NaN` values
321321
to be farthest from the top or bottom, respectively. Histogram samples in the
322-
input vector are ignored, flagged by an info-level annotation.
322+
input vector are ignored, flagged by an info-level annotation.
323+
324+
If used in an instant query, `topk` and `bottomk` return series ordered by
325+
value in descending or ascending order, respectively. If used with `by` or
326+
`without`, then series within each bucket are sorted by value, and series in
327+
the same bucket are returned consecutively, but there is no guarantee that
328+
buckets of series will be returned in any particular order. No sorting applies
329+
to range queries.
323330

324331
`limitk` and `limit_ratio` also return a subset of the input samples, including
325332
the original labels in the result vector. The subset is selected in a
@@ -334,7 +341,7 @@ the input samples, while `limit_ratio(-0.9, ...)` returns precisely the
334341
remaining approximately 90% of the input samples not returned by
335342
`limit_ratio(0.1, ...)`.
336343

337-
`group` and `count` do not do not interact with the sample values,
344+
`group` and `count` do not interact with the sample values,
338345
they work in the same way for float samples and histogram samples.
339346

340347
`count_values` outputs one time series per unique sample value. Each series has

0 commit comments

Comments
 (0)