Metric Types: Summary
What you'll learn: How Prometheus uses the Summary metric type to calculate quantiles (like median or 95th percentile) directly on the client side with sliding time windows.
What is a Summary?
A Summary is like a histogram's sophisticated cousin that does the math work upfront. While histograms bucket values and let Prometheus calculate quantiles later, summaries calculate quantiles (percentiles) on the application side before sending them to Prometheus. Think of it as pre-computing your statistics at the source rather than aggregating them centrally.
How Summaries Work
When you configure a summary metric, you specify which quantiles you care about (e.g., 0.5 for median, 0.95 for 95th percentile, 0.99 for 99th percentile) and a sliding time window (like "observe the last 10 minutes"). The client library maintains a running calculation of these quantiles as observations arrive.
For example, tracking API response times:
- You observe:
120ms,95ms,200ms,110ms... - The summary calculates:
p50 = 115ms,p95 = 195ms,p99 = 199ms - These pre-calculated values get scraped by Prometheus
Summaries vs Histograms
Summaries offer precise quantiles without configuring buckets, but come with trade-offs:
- ✅ Exact percentile values
- ✅ No bucket configuration needed
- ❌ Cannot aggregate across instances (each calculates independently)
- ❌ Higher client-side CPU/memory cost
- ❌ Quantiles fixed at instrumentation time
Use summaries when you need exact percentiles for a single service instance and won't need to aggregate across multiple instances or adjust percentiles later.
Key Takeaway: Summaries calculate quantiles client-side with configurable time windows, providing precise percentile values but sacrificing aggregation flexibility—choose them when accuracy matters more than aggregation needs.