Your dashboard shows the average of per-pod p99 latencies. Why is it wrong, and how do you compute a correct fleet-wide p99?
IntermediateScenarioPrometheus and PromQL at Scale
Answer
Situation read → Percentiles cannot be averaged. A p99 of 50 ms on one pod and 2 s on another does not average to anything meaningful.
What I'd do → Aggregate histogram buckets first, then compute the quantile:
histogram_quantile(0.99,
sum by (le, service) (rate(http_request_duration_seconds_bucket[5m])))
- Always keep
lein thebyclause. - Do not use
summaryquantiles for cross-instance aggregation, since they are pre-computed per instance. - Make a recording rule for the expression for faster dashboards.
Why → Histogram buckets are counters and are additive across instances, so summing them gives the correct combined distribution.
Interview tip → "Summaries can't be aggregated; histograms can." Say it clearly.
More on Prometheus and PromQL at Scale
Prometheus memory has grown to 60 GB and keeps climbing. How do you find the cause?IntermediateA developer added `user_id` as a metric label. What is the problem and what do you advise?BeginnerChoose histogram bucket boundaries for a service with a 300 ms latency SLO.AdvancedYou have 500 short-lived batch jobs that finish before Prometheus can scrape them. How do you capture their metrics?IntermediateYour EC2 fleet autoscales constantly. How do you keep Prometheus targets up to date?IntermediateYou run 3 Kubernetes clusters. Compare federation, remote_write and Thanos sidecar for a global view.Advanced