SLIs SLOs and error budgets
Measure the experience of the customer
Site reliability engineering (SRE) uses measurable service behavior to guide operational decisions. A service-level indicator (SLI) is a measured property of a service, such as the fraction of eligible requests that succeed. A service-level objective (SLO) sets a target for that indicator over a defined period. A service-level agreement (SLA) is a commitment with agreed consequences; it need not use the same target as an internal SLO. For the fictional bookstore, measure catalog requests at the client-facing boundary, not the percentage of running Pods. Define which requests count, the success criteria, the measurement point, and the window before comparing results. A ready Pod can still return errors.
Eligible: all completed catalog reads and observed timeoutsGood: successful catalog reads with the expected responseWindow: rolling 30 daysObjective: at least 99.9% good requestsCompute the error budget
Suppose the catalog recorded 995 successful requests out of 1,000 eligible requests in a teaching window. Its SLI is 99.5%. For a 99.9% objective, the allowed bad fraction is 0.1%, so the budget is one bad request at this observed volume. Five bad requests use five times that budget. This is a request-based budget, not an allowance of downtime minutes. The allowed count changes as traffic changes. A negative remaining budget signals that the objective has already been exceeded; it does not predict future traffic. A team may pause risky releases according to its agreed policy rather than automatically stopping all changes.
SLI = 995 / 1000 = 99.5%Allowed bad = 1000 * (1 - 0.999) = 1Observed bad = 5Remaining = 1 - 5 = -4 requestsUse burn rate to detect fast budget loss
Burn rate is the observed bad fraction divided by the allowed bad fraction. At a 99.9% objective, a 1.44% error rate gives a burn rate of 14.4. Under a constant request rate, sustaining that for one hour would consume 2% of a 30-day budget: 14.4 × 1 / 720. Traffic variation changes the relationship between time and consumed request budget. A short-window check combined with a longer-window check can avoid paging for an already recovered spike. For example, require both five-minute and one-hour burn rates to exceed 14.4, and use another slower alert for sustained degradation. These thresholds are illustrative, not universal; choose thresholds with service owners and test alert sensitivity.
1h: 2% bad / 0.1% allowed = 20x5m: 1.8% bad / 0.1% allowed = 18xBoth exceed 14.4x -> candidate pageIf 5m falls to 0.05% -> 0.5x -> fast alert clearsBuild a request-weighted query
The following PromQL is a static query for a synthetic counter named catalog_requests_total with outcome labels good and bad. Every eligible request increments exactly one outcome. Aggregate rates across replicas before dividing; averaging per-Pod percentages biases the result when loads differ. The counter must be initialized for both outcomes. This expression is only meaningful with a positive denominator and adequate scrape coverage; zero requests or missing data are not proof of health. Use separate monitoring for telemetry availability. The example uses explicit windows rather than claiming any recording rules already exist.
(sum(rate(catalog_requests_total{outcome="bad"}[5m])) / sum(rate(catalog_requests_total[5m]))) / 0.001Measure latency without averaging percentiles
For a latency objective such as 95% of eligible requests complete within 300 ms, count good events at that boundary. In a classic histogram with a 0.3-second bucket, divide the aggregated rate of the cumulative bucket by the aggregated count rate, provided they cover the same eligible population. A percentile is a distribution property: averaging per-Pod p95 values cannot recover fleet p95. For example, a Pod with 100 fast requests and a Pod with one slow request do not contribute equal weight. Missing observations require investigation; no traffic means the ratio is undefined. Practice with slo-cases.json and burn-cases.json in the lab.
sum(rate(catalog_request_duration_seconds_bucket{le="0.3"}[5m])) / sum(rate(catalog_request_duration_seconds_count[5m]))Further reading and practice
Offline practice: lab-fixtures/sre-reliability/README.md. All data are synthetic. PromQL and kubectl snippets are static and not executed. Official sources are listed in the chapter review.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
SLIs SLOs and error budgets — knowledge check
Compute request-based SLIs, error budgets and burn rates, and design useful alerts.
995 of 1000 eligible requests succeed. What is the SLI?
At a 99.9% objective and 1000 requests, what is the budget?
A 1.44% bad fraction with a 0.1% allowance gives what burn rate?
Both long and short alert windows must exceed the threshold. Only the long window does. What happens?
No eligible requests were observed. What is the availability ratio?