Latency SLO: "99% of requests under 300 ms." How do you measure it correctly in Prometheus?
IntermediateScenarioSLOs and Error Budgets
Answer
Situation read → A latency SLO is a ratio of fast requests to all requests, not a p99 gauge.
What I'd do →
- Ensure the histogram has a bucket at exactly 0.3.
- SLI = requests under 300 ms / all requests:
sum(rate(http_request_duration_seconds_bucket{job="api",le="0.3"}[5m]))
/
sum(rate(http_request_duration_seconds_count{job="api"}[5m]))
- Use this ratio in burn-rate alerts the same way as availability.
Why → Ratios aggregate correctly across pods and time; percentiles do not.
Interview tip → "Latency SLOs are counted as good events under a threshold."
More on SLOs and Error Budgets
Your company has no SLOs. A VP asks you to introduce them. Where do you begin?BeginnerChoose an SLI for a REST API: availability measured at the pod, the load balancer, or the client?IntermediateThe product owner wants a 99.99% SLO for a service that depends on a database with 99.95% availability. What do you say?IntermediateThe error budget for the month is exhausted on day 18. What happens now?IntermediateWrite an SLO in a declarative tool so teams do not hand-write burn-rate rules.AdvancedA service has 20 requests per hour overnight. One failure blows the SLO alert. How do you handle low-traffic services?Advanced