|
|
|
@ -238,23 +238,23 @@ boundaries are inclusive or exclusive.
|
|
|
|
|
## `histogram_quantile()` |
|
|
|
|
|
|
|
|
|
`histogram_quantile(φ scalar, b instant-vector)` calculates the φ-quantile (0 ≤ |
|
|
|
|
φ ≤ 1) from a [conventional |
|
|
|
|
φ ≤ 1) from a [classic |
|
|
|
|
histogram](https://prometheus.io/docs/concepts/metric_types/#histogram) or from |
|
|
|
|
a native histogram. (See [histograms and |
|
|
|
|
summaries](https://prometheus.io/docs/practices/histograms) for a detailed |
|
|
|
|
explanation of φ-quantiles and the usage of the (conventional) histogram metric |
|
|
|
|
explanation of φ-quantiles and the usage of the (classic) histogram metric |
|
|
|
|
type in general.) |
|
|
|
|
|
|
|
|
|
_Note that native histograms are an experimental feature. The behavior of this |
|
|
|
|
function when dealing with native histograms may change in future versions of |
|
|
|
|
Prometheus._ |
|
|
|
|
|
|
|
|
|
The conventional float samples in `b` are considered the counts of observations |
|
|
|
|
in each bucket of one or more conventional histograms. Each float sample must |
|
|
|
|
have a label `le` where the label value denotes the inclusive upper bound of |
|
|
|
|
the bucket. (Float samples without such a label are silently ignored.) The |
|
|
|
|
other labels and the metric name are used to identify the buckets belonging to |
|
|
|
|
each conventional histogram. The [histogram metric |
|
|
|
|
The float samples in `b` are considered the counts of observations in each |
|
|
|
|
bucket of one or more classic histograms. Each float sample must have a label |
|
|
|
|
`le` where the label value denotes the inclusive upper bound of the bucket. |
|
|
|
|
(Float samples without such a label are silently ignored.) The other labels and |
|
|
|
|
the metric name are used to identify the buckets belonging to each classic |
|
|
|
|
histogram. The [histogram metric |
|
|
|
|
type](https://prometheus.io/docs/concepts/metric_types/#histogram) |
|
|
|
|
automatically provides time series with the `_bucket` suffix and the |
|
|
|
|
appropriate labels. |
|
|
|
@ -262,17 +262,17 @@ appropriate labels.
|
|
|
|
|
The native histogram samples in `b` are treated each individually as a separate |
|
|
|
|
histogram to calculate the quantile from. |
|
|
|
|
|
|
|
|
|
As long as no naming collisions arise, `b` may contain a mix of conventional |
|
|
|
|
As long as no naming collisions arise, `b` may contain a mix of classic |
|
|
|
|
and native histograms. |
|
|
|
|
|
|
|
|
|
Use the `rate()` function to specify the time window for the quantile |
|
|
|
|
calculation. |
|
|
|
|
|
|
|
|
|
Example: A histogram metric is called `http_request_duration_seconds` (and |
|
|
|
|
therefore the metric name for the buckets of a conventional histogram is |
|
|
|
|
therefore the metric name for the buckets of a classic histogram is |
|
|
|
|
`http_request_duration_seconds_bucket`). To calculate the 90th percentile of request |
|
|
|
|
durations over the last 10m, use the following expression in case |
|
|
|
|
`http_request_duration_seconds` is a conventional histogram: |
|
|
|
|
`http_request_duration_seconds` is a classic histogram: |
|
|
|
|
|
|
|
|
|
histogram_quantile(0.9, rate(http_request_duration_seconds_bucket[10m])) |
|
|
|
|
|
|
|
|
@ -283,9 +283,9 @@ For a native histogram, use the following expression instead:
|
|
|
|
|
The quantile is calculated for each label combination in |
|
|
|
|
`http_request_duration_seconds`. To aggregate, use the `sum()` aggregator |
|
|
|
|
around the `rate()` function. Since the `le` label is required by |
|
|
|
|
`histogram_quantile()` to deal with conventional histograms, it has to be |
|
|
|
|
`histogram_quantile()` to deal with classic histograms, it has to be |
|
|
|
|
included in the `by` clause. The following expression aggregates the 90th |
|
|
|
|
percentile by `job` for conventional histograms: |
|
|
|
|
percentile by `job` for classic histograms: |
|
|
|
|
|
|
|
|
|
histogram_quantile(0.9, sum by (job, le) (rate(http_request_duration_seconds_bucket[10m]))) |
|
|
|
|
|
|
|
|
@ -293,7 +293,7 @@ When aggregating native histograms, the expression simplifies to:
|
|
|
|
|
|
|
|
|
|
histogram_quantile(0.9, sum by (job) (rate(http_request_duration_seconds[10m]))) |
|
|
|
|
|
|
|
|
|
To aggregate all conventional histograms, specify only the `le` label: |
|
|
|
|
To aggregate all classic histograms, specify only the `le` label: |
|
|
|
|
|
|
|
|
|
histogram_quantile(0.9, sum by (le) (rate(http_request_duration_seconds_bucket[10m]))) |
|
|
|
|
|
|
|
|
@ -307,7 +307,7 @@ assuming a linear distribution within a bucket.
|
|
|
|
|
If `b` has 0 observations, `NaN` is returned. For φ < 0, `-Inf` is |
|
|
|
|
returned. For φ > 1, `+Inf` is returned. For φ = `NaN`, `NaN` is returned. |
|
|
|
|
|
|
|
|
|
The following is only relevant for conventional histograms: If `b` contains |
|
|
|
|
The following is only relevant for classic histograms: If `b` contains |
|
|
|
|
fewer than two buckets, `NaN` is returned. The highest bucket must have an |
|
|
|
|
upper bound of `+Inf`. (Otherwise, `NaN` is returned.) If a quantile is located |
|
|
|
|
in the highest bucket, the upper bound of the second highest bucket is |
|
|
|
|