An SLO turns "is the service good enough?" into a number you can alert on. Pick an SLI, the share of requests that were good; pick an objective, 99.9 percent over 30 days; and the rest, 0.1 percent, is an error budget you are allowed to spend. A burn rate says how fast you are spending it, and the best page is not "errors are above 1 percent" but "at this rate the month's budget is gone in two days, and it is still happening right now". This lesson follows one bad deploy from the first failed request to the alert that resolves after the fix, and shows why a slow leak should open a ticket, why a quiet-night blip should page nobody, and how to write the Prometheus rules that get both right.
Difficulty: Advanced · Know this first: Lesson 156, Lesson 152, Lesson 157
This bar splits the time from the first error to the alert resolving, in minutes. It is a worked example, not a measurement. In the fast burn the human and the fix are most of it; in the slow leak, waiting for working hours is; on the quiet night, all of it is wasted.
Choose the SLO and the error rate you are seeing. The burn rate says how fast the 30-day budget is going, and which of the three standard alerts would fire if it kept going.
budget = 1 − SLO · burn rate = error rate ÷ budget · hours until empty = 720 ÷ burn rate · page at 14.4x (1h and 5m) or 6x (6h and 30m), ticket at 1x (3d and 6h)
Page now: the month's budget is gone by tonight
Three questions. No score is saved anywhere — this is just you against the material.
SLOs grow in four levels: first what an SLI, an SLO, and a budget are, then writing the SLI and recording rules, then multi-window burn-rate alerts, and finally running a budget policy across teams.
At the basic level you can define the terms. An SLI (service level indicator) is a measured ratio: good requests ÷ valid requests. An SLO (objective) is the target for that ratio over a window: 99.9 percent of requests good over 30 days. The error budget is what is left: 0.1 percent of requests, or about 43 minutes of full outage a month. An SLA is a contract with money attached, and is looser than the SLO.
Analogy: a monthly phone data plan. You are allowed to use it; the question is how fast.
Where it breaks: picking 100 percent. No real service meets it, and a target nobody meets is a target nobody uses.
Try it: Basic
A 99.9 percent SLO over 30 days allows roughly how much full outage?
Now do it: For one service you run, write its SLI as a fraction: which events count as good, and which as valid.
At the intermediate level you write the SLI from real metrics and record it. Measure where users are: the load balancer or ingress, not a single pod. Exclude what is not the service's fault (client 4xx), and decide what "good" means for latency (a threshold, such as under 300 ms).
Troubleshooting: an SLI that is always 100 percent is usually measuring the wrong thing, such as health checks.
Try it: Intermediate
Your availability SLI counts 404 responses as errors, and a crawler drives the SLI below target. What do you change?
Now do it: Write the recording rules in Go deeper for one of your services and check each one returns data in the Prometheus UI.
At the advanced level you alert on burn rate, not on raw error rate. The common set, from the Google SRE workbook, for a 30-day SLO:
Each alert needs both windows above the threshold: the long one for significance, the short one for recency and quick resolution. Low-traffic services need care: at 100 requests an hour, one error is 1 percent; use longer windows, synthetic traffic, or a minimum request count in the rule.
Observability: every page carries the SLO name, the burn rate, the budget spent, a dashboard link, and a runbook link.
Try it: Advanced
A burn-rate alert keeps firing for an hour after every rollback. What is missing?
Now do it: Run burn_rate.py in Go deeper and change the "10 min after the rollback" case to have no short window. Watch the alert keep firing.
At the master level the SLO drives decisions, not just pages. A written error budget policy says what happens when the budget is spent: feature releases pause or need extra review, the next sprint goes to reliability, and the policy is agreed with product owners before the first breach.
Trade-off: a tight SLO makes reliability visible and slows shipping; a loose one ships faster and lets users suffer quietly. The budget is the negotiated middle.
Try it: Master
A checkout journey calls three services in series, each with a 99.9 percent SLO. What is the best the journey can promise?
Now do it: Draft an error budget policy for one service: what happens at 50 percent spent, at 100 percent, and who signs it.
Burn rates and the multi-window rule are short enough to check by hand. This script computes the budget, the burn rate for a few error rates, and which of the three standard alerts each case would fire. Standard library only; python3 burn_rate.py.
# burn_rate.py - error budgets, burn rates, and the multi-window alerts that page on them
SLO = 0.999
BUDGET = 1 - SLO # 0.1% of requests may fail
WINDOW_MIN = 30 * 24 * 60 # a 30-day SLO window, in minutes
def burn(error_rate):
return error_rate / BUDGET
def hours_to_empty(error_rate):
return WINDOW_MIN / burn(error_rate) / 60
print(f"SLO {SLO:.1%}: budget {BUDGET:.1%} of requests = {BUDGET * WINDOW_MIN:.1f} minutes of full outage per 30 days")
for er in [0.001, 0.005, 0.0144, 0.10, 1.0]:
print(f" error rate {er:6.2%} -> burn {burn(er):6.1f}x -> budget empty in {hours_to_empty(er):6.1f} h")
# Multi-window, multi-burn-rate alerts: both the long and the short window must burn fast.
ALERTS = [("page, fast burn", "1h", "5m", 14.4), ("page, medium burn", "6h", "30m", 6.0), ("ticket, slow burn", "3d", "6h", 1.0)]
def fired(rates):
hits = [name for name, lw, sw, t in ALERTS if burn(rates[lw]) >= t and burn(rates[sw]) >= t]
return hits or ["nothing"]
cases = {
"bad deploy, 10% errors for 10 min": {"5m": 0.10, "30m": 0.033, "1h": 0.0167, "6h": 0.0028, "3d": 0.00004},
"slow leak, 0.5% for two days": {"5m": 0.005, "30m": 0.005, "1h": 0.005, "6h": 0.005, "3d": 0.0033},
"quiet night, 3 errors in 200": {"5m": 0.015, "30m": 0.0025, "1h": 0.00125, "6h": 0.0002, "3d": 0.0001},
"10 min after the rollback": {"5m": 0.0, "30m": 0.033, "1h": 0.0167, "6h": 0.0028, "3d": 0.00004},
}
for name, rates in cases.items():
print(f"{name:36} -> {', '.join(fired(rates))}")
static = cases["quiet night, 3 errors in 200"]["5m"] > 0.01
print(f"a static 'errors > 1% for 5m' rule on the quiet night -> {'pages someone' if static else 'stays quiet'}")
$ python3 burn_rate.py SLO 99.9%: budget 0.1% of requests = 43.2 minutes of full outage per 30 days error rate 0.10% -> burn 1.0x -> budget empty in 720.0 h error rate 0.50% -> burn 5.0x -> budget empty in 144.0 h error rate 1.44% -> burn 14.4x -> budget empty in 50.0 h error rate 10.00% -> burn 100.0x -> budget empty in 7.2 h error rate 100.00% -> burn 1000.0x -> budget empty in 0.7 h bad deploy, 10% errors for 10 min -> page, fast burn slow leak, 0.5% for two days -> ticket, slow burn quiet night, 3 errors in 200 -> nothing 10 min after the rollback -> nothing a static 'errors > 1% for 5m' rule on the quiet night -> pages someone
Read it like this: a 10 percent error rate empties a 99.9 percent budget in about 7 hours and pages; a 0.5 percent leak opens only a ticket; three errors on a quiet night trip a static rule and nothing else; and ten minutes after the rollback the fast-burn alert is already clear because the 5-minute window is.
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: checkout-slo
namespace: monitoring
spec:
groups:
- name: checkout-slo-recording
rules:
- record: slo:sli_error:ratio_rate5m
expr: sum(rate(http_requests_total{job="checkout",code=~"5.."}[5m])) / sum(rate(http_requests_total{job="checkout"}[5m]))
- record: slo:sli_error:ratio_rate30m
expr: sum(rate(http_requests_total{job="checkout",code=~"5.."}[30m])) / sum(rate(http_requests_total{job="checkout"}[30m]))
- record: slo:sli_error:ratio_rate1h
expr: sum(rate(http_requests_total{job="checkout",code=~"5.."}[1h])) / sum(rate(http_requests_total{job="checkout"}[1h]))
- record: slo:sli_error:ratio_rate6h
expr: sum(rate(http_requests_total{job="checkout",code=~"5.."}[6h])) / sum(rate(http_requests_total{job="checkout"}[6h]))
- record: slo:sli_error:ratio_rate3d
expr: sum(rate(http_requests_total{job="checkout",code=~"5.."}[3d])) / sum(rate(http_requests_total{job="checkout"}[3d]))
- name: checkout-slo-alerts
rules:
- alert: CheckoutErrorBudgetFastBurn
expr: slo:sli_error:ratio_rate1h > (14.4 * 0.001) and slo:sli_error:ratio_rate5m > (14.4 * 0.001)
for: 2m
labels:
severity: page
annotations:
summary: "Checkout is spending its 30-day error budget 14x too fast"
runbook_url: "https://runbooks.example.com/checkout/error-budget"
- alert: CheckoutErrorBudgetMediumBurn
expr: slo:sli_error:ratio_rate6h > (6 * 0.001) and slo:sli_error:ratio_rate30m > (6 * 0.001)
for: 15m
labels:
severity: page
- alert: CheckoutErrorBudgetSlowBurn
expr: slo:sli_error:ratio_rate3d > 0.001 and slo:sli_error:ratio_rate6h > 0.001
for: 1h
labels:
severity: ticket
The rules were parsed as YAML and follow the Prometheus rule format; before you load them, check the expressions with promtool check rules on the spec part, and adjust the metric and label names to your exporter. A 3-day rate() over raw samples is expensive; at scale, record a 5-minute ratio and average it over 3 days, or use a tool such as Sloth or Pyrra that generates these rules from a short SLO file.
This is a composite of a failure pattern that keeps repeating; the numbers are illustrative. A team alerted on "error rate above 2 percent for 10 minutes" and nothing else.
The static alert was replaced by the three burn-rate alerts, with the slow-burn one as a ticket. Night pages for blips stopped, because the 1-hour window ignores three errors, and the 1 percent leak, a 10x burn against the 99.9 percent SLO, now pages within the hour through the 6x rule. An alert that wakes people for nothing is not just annoying; it trains them to mute the one that matters.
Define SLOs and alerts for a payments API with a public checkout endpoint (200 requests a second at peak, 5 a second at night) and an internal refunds endpoint (2 requests a second).
What do users of each endpoint notice: errors, slowness, or both? Where can you measure them? What do the dependencies promise? How low does traffic go at night? What should happen to releases when the budget is spent?
Say a 99.95 percent availability SLO and a "95 percent under 400 ms" latency SLO for checkout, 99.9 percent for refunds, 30-day windows, and 15-day Prometheus retention with a long-term store behind it.
Checkout: availability and latency SLIs from the ingress, recording rules over 5m to 3d, the three burn-rate alerts with page and ticket severities, and a minimum-traffic guard so one error at night cannot page. Refunds: a single availability SLO over a longer window with the slow-burn alert only, plus a synthetic probe so the SLI has traffic. A dashboard per SLO with budget remaining, and a policy that freezes non-urgent releases when the budget is under 20 percent.
Tighter SLOs catch problems sooner and page more; looser ones are quieter and let more users down. Long windows are accurate and need retention and expensive queries. Synthetic traffic gives low-traffic services a usable SLI and measures a path real users may not take.