Skip to content

New PromQL function, histogram_quantiles (variadic) #16464

Description

@linasm

Proposal

Proposal:
Introduce a new PromQL function, histogram_quantiles(b instant-vector, φ0 scalar, ...), as a variadic implementation of histogram_quantile, capable of computing and returning multiple quantiles in one query. The results for each quantile would be differentiated by a synthetic label (say, __hist_quantile__), the value of which would be a value of quantile argument which was used to compute the given result. The function would work with both classic and native histograms.

For example:

histogram_quantiles(single_histogram, 0, 0.5, 0.9, 1)
    {__hist_quantile__="0"}   0.5
    {__hist_quantile__="0.5"} 1.414213562373095
    {__hist_quantile__="0.9"} 3.0314331330207964
    {__hist_quantile__="1"}   4

Motivation:
Dashboards that are rendering multiple quantiles on a single panel. Currently, the user experience suffers, because the singular histogram_quantile query (sometimes with a really complicated argument) has to be repeated (and later maintained) separately for each quantile (have seen 5 or even more in practice).
Additionally, having this result available from a single query would improve dashboard performance and reduce query load on the system.

Alternatives:
Arguably, this way of rendering a histogram somewhat competes with heatmap graphs, but for many use cases, plotting concrete quantiles is more precise, discrete and easier to consume:
Image

Prior art:
There was a similar proposal discussed in 2016: #1547
However, it seems it was targeting a different use case (recording rules), besides, 9 years have passed since then.

Implementation:
The function would reuse funcHistogramQuantile called for each value of quantile argument, in a loop.
Can help with the implementation in case this feature request gets accepted.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions