Tools / Monitoring and Observability Interview Questions
What is a metric histogram and why is it used for latency measurement?
A histogram is a metric type that samples observations and counts them into configurable buckets, while also tracking a running count and sum. In Prometheus, a histogram metric creates multiple time-series: _bucket{le="0.1"} (count of observations ≤ 100 ms), _bucket{le="0.5"}, _bucket{le="1.0"}, etc., plus _count (total observations) and _sum (sum of all observed values).
For latency measurement, histograms are preferred over gauges or counters because they enable percentile calculations without storing every individual data point. The histogram_quantile(0.99, rate(http_request_duration_seconds_bucket[5m])) PromQL expression computes an approximate p99 from the bucket counts — not from raw samples.
The approximation quality depends on bucket placement. Buckets should be placed where percentile boundaries are likely to fall. If your SLO threshold is 500 ms, you need a bucket at exactly 0.5 seconds; otherwise the quantile approximation at that threshold will be inaccurate.
Prometheus Native Histograms (introduced experimentally in Prometheus 2.40) eliminate the need for pre-configured buckets by using a sparse representation with exponentially-spaced buckets that adapt to the actual data distribution, providing accurate percentiles at any threshold without bucket configuration.
A summary is an alternative that computes quantiles client-side and exposes them directly. Summaries are accurate but cannot be aggregated across instances — avg(summary_quantile) across 10 pods is mathematically incorrect. Histograms aggregate correctly because bucket counts can be summed.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
