the alert says error rate > 1% for 5m. it fires at three in the morning because a single pod restarted and forty requests failed in a quiet hour, and by the time anyone has opened a laptop it has resolved itself. the next week a bad deploy returns errors on 0.8% of requests for four days straight. nothing fires, because 0.8% is under the line, and the first anyone hears of it is a customer asking why one in a hundred checkouts fails.
both failures come from the same place. a fixed threshold over a fixed window answers “is the error rate high right now”. on-call needs to know whether users are being hurt enough, for long enough, that someone should get out of bed. a service level objective puts a number on “enough”, and a burn-rate alert pages on how fast that number is being used up.
the short version
an slo of 99.9% over 30 days allows 0.1% of requests to fail. that allowance is the error budget. burn rate is how fast it is being spent, as a multiple of the rate that would use it up exactly at the end of the 30 days.
the alert pages when the burn rate is high over a long window and still high over a short one:
┌─ 1h error ratio > 14.4 x 0.001 ─┐
http_requests_total ─▶ rate by job ─┤ ├─ and ─▶ page
└─ 5m error ratio > 14.4 x 0.001 ─┘the long window decides whether enough budget has gone to matter. the short window decides whether it is still going. the first keeps a blip from paging; the second makes the page resolve minutes after the problem does, rather than an hour later. two such pairs page, one fast and one slower, and a third pair over days opens a ticket.
the error budget
an sli is a ratio of good events to all events, measured somewhere users would notice. for an http service the usual one is the share of requests that did not return a 5xx. the slo is the target for that ratio over a period - 99.9% over a rolling 30 days, say. the budget is whatever the target leaves over. 0.1% of 30 days is 43.2 minutes of total outage, or four days of a 0.75% error rate, or 30 days of a steady 0.1%. all three spend the same budget, and the slo is equally broken by any of them. burn rate is the observed error ratio divided by the allowed one:
burn rate = error ratio / (1 - slo)a burn rate of 1 means errors at exactly 0.1%, which spends the whole budget in exactly 30 days. a burn rate of 14.4 spends it in a little over two days. a full outage against a 99.9% slo is a burn rate of 1000, and spends the month’s budget in 43 minutes.
the budget spent in an alert window is the burn rate times the window, over the period. at 14.4x for one hour, that is 14.4 / 720 hours, or 2% of the month. every threshold below is chosen by deciding what share of budget is worth a page, and working backwards.
why one window is not enough
any alert can be judged on four things. precision is how many of the alerts were about something that mattered. recall is how many of the things that mattered produced an alert. detection time is how long a real problem takes to page. reset time is how long the alert keeps firing after the problem is fixed.
a single threshold over a single window trades these against each other, and it cannot get all four:
- error ratio above 0.1% over 10 minutes detects a full outage in under a second, but a 10 minute burst at exactly the slo spends 0.02% of the budget. the service could page 144 times a day and still meet its objective. recall is perfect and precision is close to zero.
- a longer window, say 36 hours sized to 5% of the budget, has good precision. it also keeps firing for 36 hours after the fix, and takes over two minutes to notice a full outage because the denominator is a day and a half of good traffic.
- a
for:clause on the short window delays every alert by the same amount. a total outage and a slight degradation both wait the full duration before paging, and the outage has spent a large share of the budget by then. - burn rate over one hour, at 14.4x, gets precision and detection right: it fires only when 2% of the budget has gone in an hour, and a total outage crosses the line within a minute. reset time is still the full hour, and anything burning below 14.4x - a 10x burn that empties the budget in three days - never fires at all.
the last one is close. the multiwindow, multi-burn-rate approach in the google sre workbook fixes its two remaining problems: several burn rates cover the slow leaks, and a short window on each one fixes the reset time.
the windows
the workbook’s recommended starting point for a 30-day slo:
| severity | long window | short window | burn rate | budget spent |
|---|---|---|---|---|
| page | 1h | 5m | 14.4 | 2% |
| page | 6h | 30m | 6 | 5% |
| ticket | 3d | 6h | 1 | 10% |
the short window is a twelfth of the long one. it is short enough that the alert stops firing a few minutes after the error rate drops, and long enough that it does not flap on a single bad scrape.
the 1h pair catches a sharp failure. the 6h pair catches a degradation that is serious but not dramatic - a 6x burn empties the budget in five days. the 3d ticket catches the slow leak from the introduction: a 0.8% error rate is an 8x burn, which the 6h pair would page on, but a 1.5x burn goes unnoticed by both pages and still breaks the slo in 20 days. that is not worth waking anyone for, and it is worth someone looking at this week.
recording rules
the alerts compare an error ratio over five windows. computing those ratios inside the alert expression means prometheus recalculates a 3-day rate on every evaluation, so each one is a recording rule:
groups:
- name: slo-payments-availability
rules:
- record: job:slo_errors_per_request:ratio_rate5m
expr: |
sum by (job) (rate(http_requests_total{job="payments", code=~"5.."}[5m]))
/
sum by (job) (rate(http_requests_total{job="payments"}[5m]))
- record: job:slo_errors_per_request:ratio_rate30m
expr: |
sum by (job) (rate(http_requests_total{job="payments", code=~"5.."}[30m]))
/
sum by (job) (rate(http_requests_total{job="payments"}[30m]))
- record: job:slo_errors_per_request:ratio_rate1h
expr: |
sum by (job) (rate(http_requests_total{job="payments", code=~"5.."}[1h]))
/
sum by (job) (rate(http_requests_total{job="payments"}[1h]))
- record: job:slo_errors_per_request:ratio_rate6h
expr: |
sum by (job) (rate(http_requests_total{job="payments", code=~"5.."}[6h]))
/
sum by (job) (rate(http_requests_total{job="payments"}[6h]))
- name: slo-payments-availability-slow
interval: 5m
rules:
- record: job:slo_errors_per_request:ratio_rate3d
expr: |
sum by (job) (rate(http_requests_total{job="payments", code=~"5.."}[3d]))
/
sum by (job) (rate(http_requests_total{job="payments"}[3d]))the sum happens before the division. averaging per-instance ratios gives an instance serving ten requests the same weight as one serving ten thousand, which is not what users experience. the names follow prometheus’s level:metric:operations convention, and they keep job as the only label so that the alerting rules can join them.
the 3-day rule is in its own group with a five minute interval. it reads three days of raw samples for every series it touches, and the ticket it feeds does not need to be fresher than that.
alerting rules
the two paging pairs go into one alert, joined with or, and the ticket goes into another:
groups:
- name: slo-payments-availability-alerts
rules:
- alert: PaymentsErrorBudgetBurn
expr: |
(
job:slo_errors_per_request:ratio_rate1h{job="payments"} > (14.4 * 0.001)
and
job:slo_errors_per_request:ratio_rate5m{job="payments"} > (14.4 * 0.001)
)
or
(
job:slo_errors_per_request:ratio_rate6h{job="payments"} > (6 * 0.001)
and
job:slo_errors_per_request:ratio_rate30m{job="payments"} > (6 * 0.001)
)
labels:
severity: page
annotations:
summary: "payments is spending its 30-day error budget too fast"
description: "1h error ratio {{ $value | humanizePercentage }} against a 0.1% budget."
runbook_url: "https://runbooks.kontrolplane.dev/payments/error-budget-burn"
- alert: PaymentsErrorBudgetBurnSlow
expr: |
job:slo_errors_per_request:ratio_rate3d{job="payments"} > (1 * 0.001)
and
job:slo_errors_per_request:ratio_rate6h{job="payments"} > (1 * 0.001)
labels:
severity: ticket
annotations:
summary: "payments will miss its slo at the current error rate"
runbook_url: "https://runbooks.kontrolplane.dev/payments/error-budget-burn"there is no for: clause. the short window already does what for: was meant to do - require the problem to persist - without adding a fixed delay to a total outage.
and in promql is a join, not a boolean. it keeps the left-hand series only where a right-hand series has exactly the same labels. both sides here carry only job, so they match. a recording rule that kept instance or route on one side and not the other would make the and silently match nothing, and the alert would never fire.
the severity label is what alertmanager routes on: page to the on-call rotation, ticket to the team’s queue. the description is only right for one of the pairs. $value is the value of whichever series made it to the end of the expression, so when the 6h pair fires it reports the 6h ratio, not the 1h one the text claims. either word it to fit both pairs, or split the pairs into two alerts with their own text.
the runbook link
runbook_url is a convention. prometheus treats it as an annotation like any other, and alertmanager passes it to the notification template. kube-prometheus uses the same name on every rule it ships, and most templates for slack and pagerduty look for it.
the runbook for a burn-rate alert has a different job from one for a cpu alert. the page says users are being hurt and the budget is going; it does not say why. the runbook is where the next three steps live: the dashboard that splits the error ratio by route and by status code, the deploy history for the last few hours, and the command that rolls back the last release. an alert that names a symptom without the first step toward a cause is the 2am problem with better arithmetic.
latency as an sli
availability is not the only thing users notice. a request that returns a 200 after eight seconds is a failure to the person waiting for it. a latency sli counts requests slower than a threshold as bad, and the same burn-rate machinery applies. with a classic prometheus histogram, the count of requests under the threshold is the bucket with that upper bound:
- record: job:slo_slow_per_request:ratio_rate5m
expr: |
1 - (
sum by (job) (rate(http_request_duration_seconds_bucket{job="payments", le="0.25"}[5m]))
/
sum by (job) (rate(http_request_duration_seconds_count{job="payments"}[5m]))
)the threshold has to be an existing bucket boundary, and le has to match its label value as a string. client_golang’s default buckets include 0.25, so 250ms works out of the box; 300ms does not exist, and le="0.3" returns nothing. the bucket layout is a decision made in the application, and it needs to be made with the slo threshold in mind. native histograms remove the constraint: histogram_fraction(0, 0.3, ...) estimates the share below any value by interpolation, at the cost of the answer being an estimate.
latency slos are usually looser than availability ones - 99% of requests under 250ms, rather than 99.9% - and the burn-rate thresholds scale with the budget. at a 99% target the 1h pair compares against 14.4 * 0.01.
low-traffic services
burn rate is a ratio, and a ratio over a handful of requests swings wildly. a service handling 10 requests an hour has a 1h window of 10 requests. one failure is a 10% error ratio, a 100x burn against a 99.9% slo, and a page. the 30-day budget at that volume is about seven failed requests in total, so the page is arguably correct and almost certainly unwanted. the workbook lists the options, none of them free:
- generate traffic. a synthetic probe that exercises the real path keeps the denominator large enough to be meaningful. it also measures the probe, not users.
- combine services. several small services behind one user-facing flow can share one slo, measured at the flow.
- make failures cheaper. retries and fallbacks in the client mean a single server-side failure is not a failed user action, and the sli can measure the action instead.
- lower the objective or lengthen the period. a service that cannot tell 99.9% from 99% with the traffic it has does not have a 99.9% slo.
a pragmatic addition is a minimum event count on the paging condition, so that the 1h pair also requires, say, at least 50 requests in the hour:
(
job:slo_errors_per_request:ratio_rate1h{job="payments"} > (14.4 * 0.001)
and
job:slo_errors_per_request:ratio_rate5m{job="payments"} > (14.4 * 0.001)
and
sum by (job) (increase(http_requests_total{job="payments"}[1h])) > 50
)the parentheses matter. and binds tighter than or, so a condition appended to the end of the full paging expression attaches only to the 6h pair, and the 1h pair pages on ten requests exactly as before. the minimum count trades recall for precision explicitly, which is better than doing it by accident.
what to watch out for
the server cannot see its own outages. a 5xx counted by the application misses every request that never reached it - a crashed pod behind a load balancer, a broken ingress, a dns failure. measure the sli at the edge closest to the user that is still under your control: the ingress controller or the load balancer.
no traffic is not good traffic. zero divided by zero is NaN, every comparison with NaN is false, and a service that receives nothing produces no alert. if the sli is measured at the application, pair the burn-rate alert with one on up or absent().
the slo should come from users, not from the graph. a target set to whatever the service currently achieves turns every regression into a page and every improvement into slack nobody asked for. the number should be the point at which users notice and complain.
retention has to cover the longest window. the 3d rule needs three days of raw samples, and a dashboard showing budget remaining over 30 days needs thirty. prometheus defaults to 15 days of retention, so unless that is raised the 30-day number is a 15-day one.
the label sets have to agree. a recording rule that keeps one more label than its partner breaks the and without an error. after changing any rule, check the alert expression returns a series in the prometheus ui by temporarily lowering the threshold.
more slos means more pages. every slo carries two paging conditions. a service with an slo per endpoint has a pager per endpoint. a few slos on the flows users care about page less and mean more.
references
[1] google sre workbook. “alerting on slos.”
sre.google/workbook/alerting-on-slos
[2] google sre book. “service level objectives.”
sre.google/sre-book/service-level-objectives
[3] prometheus documentation. “recording rules.”
prometheus.io/docs/practices/rules
[4] prometheus documentation. “alerting rules.”
prometheus.io/docs/prometheus/latest/configuration/alerting_rules
[5] prometheus documentation. “histograms and summaries.”
prometheus.io/docs/practices/histograms