prom_quantile

prom_quantile(prom_bucket: numeric, quantile: const numeric, [le_val: float64]?) -> float64

prom_quantile(prom_bucket, quantile, optional le_val) estimates a Prometheus-style histogram quantile from cumulative bucket counts per group. quantile must be a compile-time constant between 0 and 1. The result type is float64. This function may only appear in the aggregate verb, not in statsby, timechart, timestats, or other aggregate-family verbs, and it requires aggregate context. If le_val is omitted the compiler looks for a float64 column named le; otherwise it may read le from a single object column named one of attributes, tag, tags, label, labels, or EXTRA, and you must otherwise pass le_val explicitly. Rows with null prom_bucket values are filtered out before the histogram arrays are built.

Domain

This is an aggregate function (aggregates rows over a group in aggregate verbs).

Categories

Examples

aggregate latency_p99:prom_quantile(request_latency_bucket, 0.99), group_by(service)

Aggregates Prometheus histogram bucket counts to an approximate 0.99 quantile per service on the aggregate verb.

aggregate size_p95:prom_quantile(request_size_bucket, 0.95, float64(tag.le)), group_by(status_code)

Passes float64(tag.le) so prom_quantile reads Prometheus le boundaries from the tag object when no bare le column exists.