Skip to content

Commit

Permalink
chore: Document approx_topk keyword. (#15179)
Browse files Browse the repository at this point in the history
Co-authored-by: J Stickler <[email protected]>
  • Loading branch information
jeschkies and JStickler authored Dec 10, 2024
1 parent 2c5eabd commit f17ec74
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/sources/query/metric_queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,14 @@ Examples:
or
vector(0) # will return 0
```
## Probabilistic aggregation
The `topk` keyword lets you find the largest 1,000 elements in a data stream by sample size. When `topk` hits the maximum series limit, LogQL also supports using a probable approximation; `approx_topk` is a drop-in replacement when `topk` hits the maximum series limit.
```logql
approx_topk(k, <vector expression>)
```

It is only supported for instant queries and does not support grouping. It is useful when the cardinality of the inner
vector is too high, for example, when it uses an aggregation by a structured metadata label.

0 comments on commit f17ec74

Please sign in to comment.