Skip to content

Lesson 8 of 13 · 12m

A Summary Can't Be Averaged

Client-side quantiles never aggregate; bucket counters do — and histogram_quantile is only as honest as your le boundaries.

The average of twelve pods' p99s is not your p99. It isn't close to your p99. It is a number with no statistical meaning — quantiles don't add, average, or aggregate — and it's the value on most dashboards anyway, because the client emitted a summary instead of a histogram.

What each type actually emits

A Prometheus summary computes quantiles client-side — the Go client keeps a roughly ten-minute sliding window — and emits them as separate series: http_request_duration_seconds{quantile="0.99"}. The quantile was calculated inside that one process, over that one window, and the only thing you can do with it is graph it. There is no valid PromQL for "the p99 across all pods" from summary quantiles — avg() produces the meaningless number, max() produces the worst pod's windowed p99, and neither is the fleet p99.

A histogram emits counters: http_request_duration_seconds_bucket{le="0.3"} counting cumulative observations at each boundary, plus _sum and _count. Counters aggregate. histogram_quantile(0.99, sum(rate(http_request_duration_seconds_bucket[5m])) by (le)) pools every pod's buckets, then linearly interpolates inside the bracketing bucket to estimate the quantile. The answer is approximate — bounded by your bucket granularity — but it's the actual fleet statistic, which a summary cannot produce at any accuracy.

Accuracy lives in the bucket boundaries

histogram_quantile interpolates linearly between the le values around the target quantile, so error is proportional to bucket width at that point. The Go client's classic default buckets — .005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10 seconds — bracket a 300 ms SLO with .25 and .5: a true 280 ms p99 can report anywhere up to ~0.5 depending on distribution inside the bucket. The fix is not more buckets everywhere; it's buckets that bracket the numbers you promise. Put le boundaries at your SLOs — .1, .2, .3, .4 around a 300 ms SLO — and interpolation error shrinks to whatever the SLO gap is. prometheus.ExponentialBuckets(start, factor, count) and LinearBuckets generate the set instead of hand-typing it — and every bucket is a series per labelset, so a careless 25-bucket plan is also a cardinality decision.

Histograms also keep _sum and _count, so the mean is rate(_sum[5m]) / rate(_count[5m]). Don't drop _sum; quantiles alone can't give you a mean, and you'll want it for burn-rate SLIs that average latency rather than percentile it. There's a second asymmetry worth stating plainly: a summary fixes the quantiles it can answer at instrumentation time — ship {quantile="0.99"} and you can never ask that series for p99.9. A histogram answers any quantile you didn't think to configure.

Native histograms

Prometheus's native histograms — experimental since 2.40 in November 2022, still explicitly opt-in via feature flags in the 3.x line — replace fixed le buckets with exponential-resolution schemas: finer resolution near zero, no bucket planning, and one dense record instead of twelve-plus series per labelset, which is real cardinality relief for histogram-heavy services. OTel's exponential-buckets histograms map onto them. Until they graduate, fixed buckets with deliberate boundaries remain the boring, correct default.

Practice

  • Histograms for anything you'll ever aggregate or query as a quantile; summaries only when the quantile will never leave the single process that computed it.
  • Place le boundaries on both sides of every SLO threshold; interpolation can't save a bucket plan that skips your SLO.
  • Keep _sum/_count; they give you means for free and they're the inputs to event-ratio SLIs.
  • Never avg() quantile series. If a dashboard does it, the number is decorative.

The one-line version is the one the Prometheus docs have carried for a decade: if you need to aggregate, you need buckets.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.