SLOs & Burn-Rate Alerts
Error budgets and multi-window, multi-burn-rate alerting
Threshold alerts like "error ratio above 1% for 5 minutes" are hard to tune. Too sensitive, and they page for blips nobody noticed. Too relaxed, and a steady 0.8% error rate burns through a month of reliability without ever alerting. SLO-based alerting replaces the guesswork with arithmetic.
SLI, SLO, error budget
| Term | Meaning | Demo app |
|---|---|---|
| SLI (indicator) | A ratio of good events to total events | Non-5xx requests / all requests |
| SLO (objective) | The target for that ratio over a window | 99.5% over 30 days |
| Error budget | 1 − SLO: how much failure is acceptable | 0.5% of requests may fail |
The error budget reframes reliability as a resource. Over 30 days at 1M requests a day, a 99.5% SLO allows 150,000 failed requests. Spend them slowly through small blips, or quickly in one outage. Either way, when the budget is gone, the SLO is missed.
Users don't notice 99.99% vs 99.95%. They do notice when the product is broken. An SLO says, in a number that engineers and product managers agree on, how broken is too broken. That makes "should we page?" and "should we ship features or fix reliability?" answerable questions.
Good SLIs
An SLI should measure what users experience, as close to them as possible:
- Availability: share of requests that didn't fail (
status!~"5.."). - Latency: share of requests faster than a threshold, using an exact
bucket boundary:
rate(..._bucket{le="0.3"}) / rate(..._count). - Freshness for pipelines: share of time the data is less than N minutes old.
Measure at the load balancer or the service's edge, not deep in a dependency. Exclude what isn't the service's fault, such as 4xx client errors. And choose an SLO you can actually meet; 100% is never the right target.
Burn rate
Burn rate is how fast you're spending the budget, relative to spending it evenly over the window:
burn rate = observed error ratio / error budget
error ratio 0.5% -> burn rate 1 # exactly on budget: 30 days lasts 30 days
error ratio 5% -> burn rate 10 # budget gone in 3 days
error ratio 7.2% -> burn rate 14.4 # 2% of the 30-day budget gone in 1 hourThe Error budget burn rate panel on the RED dashboard plots this for three windows.
Multi-window, multi-burn-rate alerts
The approach from Google's SRE Workbook, and what
config/rules/alerts.yml implements:
| Severity | Long window | Short window | Burn rate | Budget spent before firing |
|---|---|---|---|---|
| Page | 1h | 5m | 14.4 | 2% |
| Page | 6h | 30m | 6 | 5% |
| Ticket | 1d | 2h | 3 | 10% |
| Ticket | 3d | 6h | 1 | 10% |
This stack has the first row as ErrorBudgetBurnFast (critical) and the
second as ErrorBudgetBurnSlow (warning).
- alert: ErrorBudgetBurnFast
expr: |
job:slo_errors:ratio_rate1h{job="demo-app"} > (14.4 * 0.005)
and
job:slo_errors:ratio_rate5m{job="demo-app"} > (14.4 * 0.005)
labels:
severity: criticalWhy two windows:
- The long window (1h) makes the alert significant. A 30-second blip can't push a 1-hour error ratio over 7.2%.
- The short window (5m) makes it resolve quickly. Without it, after you fix the problem the 1h ratio stays elevated for most of an hour and the alert keeps firing. Requiring the 5m ratio to also be high means the alert clears within minutes of recovery.
And why multiple burn rates: a fast burn needs a fast response but would miss a slow leak. The slower tiers catch a steady 2% error rate that never crosses the fast threshold but would still exhaust the budget in two weeks.
These alerts need no for clause. The windows already provide the
smoothing. Adding for: 5m just delays every page by five minutes for
no benefit.
The recording rules behind them
Each window needs its own error ratio. Computing rate(x[1d]) from raw
counters every 30 seconds is expensive, so they're recording rules:
- record: job:slo_errors:ratio_rate1h
expr: |
sum by (job) (rate(http_requests_total{job="demo-app",status=~"5.."}[1h]))
/ sum by (job) (rate(http_requests_total{job="demo-app"}[1h]))Writing these by hand for every service and window gets repetitive. Tools like Sloth and Pyrra generate the full set of recording rules, alerts, and dashboards from a short SLO spec:
# sloth spec (sketch)
slos:
- name: requests-availability
objective: 99.5
sli:
events:
error_query: sum(rate(http_requests_total{job="demo-app",status=~"5.."}[{{.window}}]))
total_query: sum(rate(http_requests_total{job="demo-app"}[{{.window}}]))Budget remaining
To show how much budget is left this month on a dashboard:
# fraction of the 30-day error budget still unspent (1 = untouched, below 0 = SLO missed)
1 - (
(1 - (sum(increase(http_requests_total{job="demo-app", status!~"5.."}[30d]))
/ sum(increase(http_requests_total{job="demo-app"}[30d]))))
/ 0.005
)Over a 30-day range that's an expensive query; in production you'd
compute it from a recorded 5-minute ratio with avg_over_time.
Lab
- Graph
job:slo_errors:ratio_rate5m{job="demo-app"} / 0.005: the current burn rate. At the default 1% error rate it sits around 1.4. (The demo app's baseline is deliberately above budget, so the slow burn alert has a reason to exist.) - Inject 30% errors, then watch the Error budget burn rate panel. The
5m line rises within minutes. The 1h line climbs slowly. Note when
ErrorBudgetBurnFastfires. - Restore the error rate. Watch the 5m line drop first and the alert resolve, while the 1h line is still high. That's the short window doing its job.
- Write an SLO for latency: 99% of
/api/ordersrequests under 100 ms. Add the recording rules and a fast-burn alert, plus apromtooltest for it.