Histogram functions
These functions operate on histogram metrics.
Returns the arithmetic average of observations stored in a native histogram.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
histogram_avg(increase(http_request_duration_seconds[5m]))
Differences from Prometheus
Accepts only native histograms. Classic histogram buckets, such as rate(x_bucket[5m]), return an error, where Prometheus returns no results.
Returns the count of observations stored in a native histogram.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
histogram_count(increase(http_request_duration_seconds[5m]))
Differences from Prometheus
Accepts only native histograms. Classic histogram buckets, such as rate(x_bucket[5m]), return an error, where Prometheus returns no results.
Returns the estimated fraction of observations of a classic or native histogram that fall between the provided lower and upper values.
Return type
instant_vector
Parameters
lower(scalar)- Lower bound of the range.
upper(scalar)- Upper bound of the range.
v(instant_vector)- Instant vector input.
Example
histogram_fraction(0, 0.2, increase(http_request_duration_seconds[1h]))
Differences from Prometheus
topk, bottomk, limitk, limit_ratio, or without(...), such as histogram_quantile(0.9, topk(5, a)), isn't supported yet. Aggregate with by(...) first, such as histogram_quantile(0.9, topk(5, sum by (job, le) (a))).
Returns the φ-quantile of a classic histogram represented by cumulative le buckets or a native (exponential) histogram.
Return type
instant_vector
Parameters
φ(scalar)- Quantile value (0 ≤ φ ≤ 1).
v(instant_vector)- Instant vector input.
Example
histogram_quantile(0.9, rate(http_request_duration_seconds_bucket[5m]))
Differences from Prometheus
A quantile that isn't a number literal, such as histogram_quantile(scalar(a), b), isn't supported yet.
topk, bottomk, limitk, limit_ratio, or without(...), such as histogram_quantile(0.9, topk(5, a)), isn't supported yet. Aggregate with by(...) first, such as histogram_quantile(0.9, topk(5, sum by (job, le) (a))).
Returns the sum of observations stored in a native histogram.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
histogram_sum(increase(http_request_duration_seconds[5m]))
Differences from Prometheus
Accepts only native histograms. Classic histogram buckets, such as rate(x_bucket[5m]), return an error, where Prometheus returns no results.