A quantile estimate inherits its histogram's resolution
Read cumulative buckets correctly, distinguish value interpolation from rank error, and preserve compatible distributions before fleet-wide quantiles.
On this page
The question for today
What you’ll understand
- Recover interval counts from classic cumulative histogram buckets.
- Calculate an interpolated quantile and state what the containing bucket actually proves.
- Aggregate compatible bucket counts before quantile estimation rather than averaging percentiles.
A p99 value looks precise even when the underlying observations were grouped into broad buckets. The estimate can only use the information the histogram retained. Bucket design therefore belongs to the measurement question: a service-level threshold may need an exact boundary, while exploration across a broad range benefits from another resolution strategy. We will separate observed counts, interpolation assumptions, and the uncertainty that a displayed decimal can hide.
Cumulative buckets are not disjoint bins
In a classic Prometheus histogram, each upper-bound bucket counts observations at or below that bound, so one observation can increment several cumulative bucket series. Subtract neighboring cumulative counts to obtain the count in the interval between their boundaries. The positive-infinity bucket covers the total observation count. Adding cumulative buckets together double-counts observations. For duration instruments with nonnegative values, sum and count can also supply a mean, but that mean alone cannot reveal how many requests lie in a slow tail.
A threshold aligned exactly with a bucket boundary can be answered from that bucket's count, subject to complete correct measurement. An arbitrary threshold inside a bucket needs an estimate or additional information about its interior. Native histograms provide another representation with their own schemas and interpolation rules; they should not be explained by pretending every format is a classic list of fixed boundaries. When merging sources, use compatible bucket semantics and populations. Incompatible layouts or mixed units require a valid conversion, not an arithmetic sum of identically named fields.
Interpolation assumes something about the hidden interior
For a finite classic bucket containing the requested rank, linear interpolation places that rank proportionally between the bucket's boundaries. The calculation assumes an interior distribution that the counts did not observe. If all values cluster near one edge, the estimate can differ substantially from the true empirical quantile while remaining inside the same bucket. Distinguish value uncertainty from a rank-error guarantee: a broad value interval and an algorithm that bounds quantile rank are different error statements. Neither should be converted into the other without assumptions about the distribution.
Do not average per-instance percentiles to obtain a service percentile. Combine compatible distribution counts, then estimate the percentile of that combined event population. A slow quiet instance and a fast busy instance can contribute very different weights. Also preserve the query window: rates of compatible bucket counters can form a recent distribution estimate, while cumulative lifetime buckets answer another question. Check invalid or nonmonotonic bucket data and missing sources instead of treating an interpolator's repaired output as proof the original measurements were healthy.
Choose resolution from decisions and cost
Place a boundary at a critical latency threshold when the decision is the fraction satisfying that threshold. Add useful resolution around changing tails without creating an uncontrolled series and storage budget. Test the instrument with distributions concentrated just below and above a boundary, not only smooth random values. Compare a known raw fixture's empirical quantile with the bucket estimate and document the permitted value interval. A chart that rounds an estimate to microseconds does not recover microsecond information from a hundred-millisecond bucket.
The probability lab is a contrast with known exact masses rather than a latency-histogram generator. Reset, set both p=0.5 and n=10, predict a symmetric distribution with mean five successes, then Play or Step. Reset and set both p=0.2 and n=10 to inspect a skewed exact distribution with mean two. Playback highlights bars and never resamples observations. These discrete count bars have exact specified masses; production latency values hidden inside a bucket do not. The model cannot select Prometheus boundaries or certify a quantile's value error.
Work it through
Locate p95 in a broad duration bucket
A complete classic duration histogram has 1,000 observations. Cumulative counts are 500 through 0.1 s, 900 through 0.2 s, and 1,000 through 0.5 s. Estimate p95 using linear interpolation.
The target rank is 0.95 × 1,000 = 950. It lies in the (0.2,0.5] second bucket, which contains 1,000 − 900 = 100 observations.
The target is fifty observations into that bucket, or half its count. Linear interpolation gives 0.2 + (50/100) × 0.3 = 0.35 seconds.
The counts only locate that rank inside the bucket; they do not establish a uniform interior. Separately, the fraction at or below the actual 0.2 s boundary is exactly 900/1,000 = 90 percent for these recorded observations.
The interpolated p95 is 350 ms, while the retained evidence locates it within the finite bucket above 200 ms through 500 ms. Boundary-aligned fractions and interior quantile estimates have different certainty.
The living notebook
Explore the model
Interactive lab · probability
Known masses versus hidden bucket interiors
Reset, set both p=0.5 and n=10, predict mean five and symmetry, then Play or Step. Reset and re-enter p=0.2 and n=10 for mean two and a skewed exact distribution. These binomial bars are exact probabilities, not latency observations or histogram interpolation; playback highlights rather than samples.
- Mean · np
- 5
- Variance · np(1−p)
- 2.5
- Total probability
- 1
These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forA displayed bar or quantile is meaningful only with its retained information and its stated interpolation assumptions.
Pause & reason
Check your understanding
Your turn
Try it yourself
A histogram has 200 observations, with 100 at or below 0.1 s and 180 at or below 0.3 s. Estimate p75 linearly inside the relevant finite bucket and state the known interval.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Find rank 150, subtract the cumulative count below the bucket, and divide by its interval count.
Compare with the solution
Rank 150 lies in (0.1,0.3], whose count is eighty. It is fifty into that bucket, giving 0.1 + (50/80) × 0.2 = 0.225 seconds. The estimate is 225 ms under uniform-interior interpolation; the retained counts themselves locate the rank above 100 ms through 300 ms.
Keep the idea
Take it with you
- Classic histogram buckets are cumulative, so interval counts require subtraction.
- Interpolated quantile values depend on the hidden-interior model and bucket resolution.
- Merge compatible distributions before estimating a pooled percentile; do not average percentiles.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.