|
|
@ -238,23 +238,23 @@ boundaries are inclusive or exclusive. |
|
|
|
## `histogram_quantile()` |
|
|
|
## `histogram_quantile()` |
|
|
|
|
|
|
|
|
|
|
|
`histogram_quantile(φ scalar, b instant-vector)` calculates the φ-quantile (0 ≤ |
|
|
|
`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 |
|
|
|
histogram](https://prometheus.io/docs/concepts/metric_types/#histogram) or from |
|
|
|
a native histogram. (See [histograms and |
|
|
|
a native histogram. (See [histograms and |
|
|
|
summaries](https://prometheus.io/docs/practices/histograms) for a detailed |
|
|
|
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.) |
|
|
|
type in general.) |
|
|
|
|
|
|
|
|
|
|
|
_Note that native histograms are an experimental feature. The behavior of this |
|
|
|
_Note that native histograms are an experimental feature. The behavior of this |
|
|
|
function when dealing with native histograms may change in future versions of |
|
|
|
function when dealing with native histograms may change in future versions of |
|
|
|
Prometheus._ |
|
|
|
Prometheus._ |
|
|
|
|
|
|
|
|
|
|
|
The conventional float samples in `b` are considered the counts of observations |
|
|
|
The float samples in `b` are considered the counts of observations in each |
|
|
|
in each bucket of one or more conventional histograms. Each float sample must |
|
|
|
bucket of one or more classic histograms. Each float sample must have a label |
|
|
|
have a label `le` where the label value denotes the inclusive upper bound of |
|
|
|
`le` where the label value denotes the inclusive upper bound of the bucket. |
|
|
|
the bucket. (Float samples without such a label are silently ignored.) The |
|
|
|
(Float samples without such a label are silently ignored.) The other labels and |
|
|
|
other labels and the metric name are used to identify the buckets belonging to |
|
|
|
the metric name are used to identify the buckets belonging to each classic |
|
|
|
each conventional histogram. The [histogram metric |
|
|
|
histogram. The [histogram metric |
|
|
|
type](https://prometheus.io/docs/concepts/metric_types/#histogram) |
|
|
|
type](https://prometheus.io/docs/concepts/metric_types/#histogram) |
|
|
|
automatically provides time series with the `_bucket` suffix and the |
|
|
|
automatically provides time series with the `_bucket` suffix and the |
|
|
|
appropriate labels. |
|
|
|
appropriate labels. |
|
|
@ -262,17 +262,17 @@ appropriate labels. |
|
|
|
The native histogram samples in `b` are treated each individually as a separate |
|
|
|
The native histogram samples in `b` are treated each individually as a separate |
|
|
|
histogram to calculate the quantile from. |
|
|
|
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. |
|
|
|
and native histograms. |
|
|
|
|
|
|
|
|
|
|
|
Use the `rate()` function to specify the time window for the quantile |
|
|
|
Use the `rate()` function to specify the time window for the quantile |
|
|
|
calculation. |
|
|
|
calculation. |
|
|
|
|
|
|
|
|
|
|
|
Example: A histogram metric is called `http_request_duration_seconds` (and |
|
|
|
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 |
|
|
|
`http_request_duration_seconds_bucket`). To calculate the 90th percentile of request |
|
|
|
durations over the last 10m, use the following expression in case |
|
|
|
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])) |
|
|
|
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 |
|
|
|
The quantile is calculated for each label combination in |
|
|
|
`http_request_duration_seconds`. To aggregate, use the `sum()` aggregator |
|
|
|
`http_request_duration_seconds`. To aggregate, use the `sum()` aggregator |
|
|
|
around the `rate()` function. Since the `le` label is required by |
|
|
|
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 |
|
|
|
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]))) |
|
|
|
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]))) |
|
|
|
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]))) |
|
|
|
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 |
|
|
|
If `b` has 0 observations, `NaN` is returned. For φ < 0, `-Inf` is |
|
|
|
returned. For φ > 1, `+Inf` is returned. For φ = `NaN`, `NaN` is returned. |
|
|
|
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 |
|
|
|
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 |
|
|
|
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 |
|
|
|
in the highest bucket, the upper bound of the second highest bucket is |
|
|
|