SENIORCHAPTER 17

Multi-window multi-burn-rate alerts

Page when the error budget is burning fast, open a ticket when it is burning slowly, stop paging minutes after it stops, and prove all of it with promtool instead of waiting three days

55 MINOBSERVABILITYUPDATED 2026-11-02
PREDICT

Checkout's SLO is 99.9% over 30 days. You page when the error ratio over the last hour exceeds 14.4 × 0.1% = 1.44%. A bad deploy makes 1% of checkouts fail and nobody notices for a week. When does the page fire?

The previous chapter recorded checkout’s two SLIs as error ratios over eight windows, with one label, slo, and the error budget for each SLO as a series of its own. This chapter turns them into alerts. It follows chapter 5 of the SRE Workbook, “Alerting on SLOs”, which walks through six designs from worst to best. You will see why the first four fail, implement the sixth exactly as specified, write it to prometheus/rules/slo-alerts.yml, and test it with promtool so that a burn that takes hours to page can be proven in seconds.

What a good alert does

The Workbook judges every design on four properties.

  • Precision: the proportion of alerts that were about something significant. Low precision is a pager that cries wolf.
  • Recall: the proportion of significant events that produced an alert. Low recall is the Friday-to-Monday 0.8%.
  • Detection time: how long from the start of the problem to the alert. A total outage should page in a minute or two; a slow leak can take hours.
  • Reset time: how long the alert keeps firing after the problem is fixed. A long reset hides the next incident behind the last one and teaches people to ignore firing alerts.

“Significant” has a precise meaning here: an event that consumes a meaningful fraction of the error budget. The Workbook’s starting points are 2% of a 30-day budget for a page in the next hour, 5% for a page over six hours and 10% for a ticket. Everything below is about hitting those fractions with good precision, recall, detection and reset at once.

Why the obvious alerts fail

1. Alert when the error ratio over 10 minutes exceeds the SLO’s ratio. For a 99.9% SLO, page when more than 0.1% of the last 10 minutes failed. Detection is excellent: a total outage pages within seconds. Precision is terrible. A 0.1% error ratio for 10 minutes spends 0.02% of the month’s budget. You could receive 144 such pages a day, act on none of them, and still meet the SLO.

2. Make the window longer. Alert when the 36-hour ratio exceeds 0.1%, which means 5% of the budget has gone. Precision improves. Reset time is now 36 hours: after a total outage the 36-hour average stays above threshold for a day and a half after the fix. And rate() over 36 hours is expensive to evaluate every few seconds.

3. Add a for: duration. Keep a short window and require the condition to hold for an hour. It looks like a cheap long window and is not. A 100% outage now pages after an hour, the same as a 0.2% trickle, and in that hour spends 140% of the 30-day budget. Worse, the timer resets the moment the value dips below the threshold, so an SLI that oscillates (100% errors for five minutes in every ten, in the Workbook’s example) never pages while it burns 35% of the budget. The Workbook’s conclusion is that durations do not belong in SLO alert criteria.

Burn rate

The fix is to stop comparing the error ratio with the SLO and start comparing it with a multiple of the budget. The burn rate is how fast the service is spending its budget relative to the SLO window:

burn rate = error ratio / (1 − SLO)

A burn rate of 1 spends exactly the whole budget by the end of the window. For a 30-day window:

Burn rate Availability error ratio (budget 0.1%) Latency error ratio (budget 1%) Budget gone in
1 0.1% 1% 30 days
2 0.2% 2% 15 days
6 0.6% 6% 5 days
10 1% 10% 3 days
14.4 1.44% 14.4% 50 hours
200 20% (FAULT_ERROR_RATE=0.2) (not reachable) 3.6 hours
1,000 100% (not reachable) 43.2 minutes

A burn-rate alert fixes the fraction of budget you are willing to lose before being told, then derives the threshold for a given window. The Workbook gives two formulas. The budget consumed when the alert fires:

budget consumed = burn rate × window / SLO period

and the time an alert takes to fire for a given error ratio:

detection time = (1 − SLO) / error ratio × window × burn rate

Want 2% of a 30-day (720-hour) budget in a 1-hour window? Burn rate 0.02 × 720 / 1 = 14.4. That is where the number comes from. Checkout at 20% errors: 0.001 / 0.2 × 60 min × 14.4 = 4.3 minutes to page. A total outage: 52 seconds.

4. Alert on one burn rate over one hour. The Workbook’s fourth design uses 36 over 1 hour (5% of the budget). Precision is good, detection is good, and reset falls to 58 minutes. Recall is the problem the Predict showed: a burn rate of 35 never alerts and still empties the budget in 20.5 hours.

5. Alert on several burn rates. Add more conditions so every significant rate has one that catches it:

Budget consumed Long window Burn rate Notification
2% 1 hour 14.4 page
5% 6 hours 6 page
10% 3 days 1 ticket

Recall is now good, because the 3-day window catches anything that spends 10% of the budget. Reset times got worse: the ticket keeps firing for up to three days after the fix. And one big incident fires all three at once, which needs suppression.

The short window

6. Multiwindow, multi-burn-rate. The sixth design keeps the table above and adds, for each condition, a second, short window at 1/12 the length of the long one. The condition fires only when both windows exceed the threshold: the long window proves enough budget has gone to matter; the short window proves it is still going.

0%4%15% errors, 10 minpage firesthreshold 14.4 × 0.1% = 1.44%5 m window (off the scale at 15%)1 h window: above threshold until minute 74020406080 min

The figure is the Workbook’s own example: 15% errors for 10 minutes against a 99.9% SLO. The 5-minute ratio crosses 1.44% almost at once; the 1-hour ratio crosses it about 6 minutes in, and the page starts. When the errors stop, the 5-minute ratio falls under the threshold within 5 minutes and the page stops. The 1-hour ratio stays above the threshold for another 50 minutes; without the short window the page would have fired for all of them. Detection time is set by the long window, reset time by the short one.

The full recommended configuration for a 99.9% SLO, Table 5-8 in the Workbook plus the 24-hour ticket condition from its final rule:

Severity Long window Short window Burn rate Budget consumed
page 1 h 5 m 14.4 2%
page 6 h 30 m 6 5%
ticket 1 d 2 h 3 10%
ticket 3 d 6 h 1 10%

Those are the seven windows slo.yml records: 5m, 30m, 1h, 2h, 6h, 1d and 3d.

The rules for checkout

The Workbook writes the thresholds as literals, (14.4*0.001), for one SLO. Checkout has two SLOs with different budgets, 0.1% for availability and 1% for latency, so the rules read the budget from the series slo:error_budget:ratio that slo.yml records, joined on the slo label:

slo:sli_error:ratio_rate1h > on(slo) (14.4 * slo:error_budget:ratio)

14.4 * slo:error_budget:ratio is a vector with one sample per SLO: 0.0144 and 0.144. The comparison with on(slo) matches each SLO’s 1-hour error ratio against its own threshold and keeps the left-hand sample where the comparison is true. One rule now covers every SLO in the file, and adding a third SLO later needs no change to the alerts.

SLO Budget 14.4× (1h, 5m) 6× (6h, 30m) 3× (1d, 2h) 1× (3d, 6h)
checkout-availability 0.1% 1.44% 0.6% 0.3% 0.1%
checkout-latency 1% 14.4% 6% 3% 1%

The two conditions of each severity are joined with and and the pairs with or, exactly as in the Workbook’s final rules. Both operators match series on their full label set ignoring the metric name, so the 1-hour series and the 5-minute series for the same slo match, and an SLO that satisfies both page conditions produces one alert, not two.

The whole file:

# Multiwindow, multi-burn-rate alerts, SRE Workbook ch. 5, Table 5-8
# (observability/burn-rate-alerts). Thresholds are burn rate x error budget,
# read per SLO from slo:error_budget:ratio in slo.yml.
groups:
  - name: slo-alerts
    rules:
      - alert: ErrorBudgetBurn
        expr: |
          (
              slo:sli_error:ratio_rate1h  > on(slo) (14.4 * slo:error_budget:ratio)
            and
              slo:sli_error:ratio_rate5m  > on(slo) (14.4 * slo:error_budget:ratio)
          )
          or
          (
              slo:sli_error:ratio_rate6h  > on(slo) (6 * slo:error_budget:ratio)
            and
              slo:sli_error:ratio_rate30m > on(slo) (6 * slo:error_budget:ratio)
          )
        labels:
          severity: page
        annotations:
          summary: "{{ $labels.slo }} is burning error budget fast (2% in 1h or 5% in 6h)"
      - alert: ErrorBudgetBurn
        expr: |
          (
              slo:sli_error:ratio_rate1d  > on(slo) (3 * slo:error_budget:ratio)
            and
              slo:sli_error:ratio_rate2h  > on(slo) (3 * slo:error_budget:ratio)
          )
          or
          (
              slo:sli_error:ratio_rate3d  > on(slo) slo:error_budget:ratio
            and
              slo:sli_error:ratio_rate6h  > on(slo) slo:error_budget:ratio
          )
        labels:
          severity: ticket
        annotations:
          summary: "{{ $labels.slo }} is burning error budget (10% in 1d or 3d)"

Three decisions are worth naming. There is no for:: the long window already demands that the burn be sustained, and a for: would add its delay to a total outage as well as to a blip. Without for:, Prometheus moves an alert straight to firing on the first evaluation where the expression returns a sample. Both rules share the name ErrorBudgetBurn and differ by the severity label, as in the Workbook; routing works on labels, and a runbook for “the budget is burning” applies to both. And every alert carries the slo label, so the notification says which promise is at risk, and later chapters can route latency and availability differently if they want to.

Page, ticket and suppression

Prometheus only evaluates rules. Sending a page to a phone and a ticket to a queue is Alertmanager’s job, routed on severity. The lab stack has no Alertmanager, so in the lab you read alerts from Prometheus’s /alerts page and its API.

One incident usually fires both severities. A fast burn spends 10% of the budget over three days too, so the ticket starts at the same time as the page, and in the lab it starts first, because a stack with little history has a short 3-day window. Alertmanager’s inhibit_rules mute the ticket while a page for the same SLO is firing:

inhibit_rules:
  - source_matchers: [ 'severity="page"' ]
    target_matchers: [ 'severity="ticket"' ]
    equal: [ alertname, slo ]

The ticket keeps firing after the page clears, up to six hours for the 3-day condition (its 6-hour short window has to drain). That is the right behaviour: someone should look at what spent 2% of the month, in working hours.

Testing alerts you cannot wait for

A slow burn takes hours to page by design. Nobody verifies that by watching. promtool test rules evaluates rule files against synthetic series on a simulated clock and asserts which alerts fire at which times. It runs the real Prometheus rule engine, so a test that passes is evidence about Prometheus v3.2.1, not about your reading of the docs.

Series are written in expanding notation: 0+300x120 means start at 0 and add 300 at each step for 120 steps. With interval: 1m that is a counter at 5 requests per second for two hours. A test lists the alerts expected at chosen eval_times, with exact labels and annotations, and an empty list asserts that nothing fires.

The lab’s test file has five cases. The timings come from running them:

Case Errors Page Ticket
fast burn, after 2 h clean 20% (burn rate 200) 4 minutes in 1 minute in
short window resets, 6 min burst after 6 h clean 20%, then 0 stops 4 to 6 minutes after the errors, while the 1 h ratio is still 2% keeps firing
latency burn, after 2 h clean 20% slower than 0.5 s (burn rate 20) between 40 and 50 minutes in within minutes
slow burn, after 6 h clean 1% (burn rate 10) 3 h 38 min in, by the 6 h branch; the 1 h branch never fires about 40 minutes in
smouldering, after 3 days clean 0.2% (burn rate 2) never between 35 and 37 hours in

The predicted times follow from the detection-time formula: 0.001 / 0.01 × 6 h × 6 = 3.6 hours for the slow burn, 0.001 / 0.002 × 72 h × 1 = 36 hours for the smouldering one. The latency case is slower than the availability one at the same 20% because its budget is ten times larger: 20% is a burn rate of 20, not 200.

A unit test also catches the mistakes promtool check rules cannot. A rule that names a series which does not exist is valid PromQL and never fires; a threshold off by a factor of ten is valid PromQL and fires at the wrong time. Only a test with realistic input and an expected time catches either.

Where burn-rate alerts go wrong

  • Low traffic. At 10 requests an hour, one failure is a 10% hourly error ratio and a burn rate of 100 against 99.9%. The rules fire on single failures because, against that SLO, a single failure really is 14% of the month’s budget. The Workbook’s remedies: generate synthetic traffic, combine related low-traffic services into one SLO, make clients retry so a single failure does not hurt a user, or lower the SLO to what a single failure is worth.
  • Extreme targets. At 90% the 14.4 condition needs a 144% error ratio and can never fire. At 99.999% a total outage spends the whole 30-day budget in 26 seconds, faster than scrape, evaluation and notification combined. The standard table assumes something between 99% and 99.99%.
  • No data is not a breach. If the gateway dies, its counters stop and every ratio has no data. None of these alerts fire. That is the gap the synthetic monitoring chapter’s probe alerts cover; see Synthetic monitoring and black-box probes.
  • Too many tuned rules. Choosing different windows and burn rates per service multiplies the numbers nobody can reason about. The Workbook advises choosing one set of parameters and applying it everywhere, grouping request types into a few classes with shared targets instead of tuning each one.
  • A ratio from a newborn counter. rate() measures increases between samples, so the first sample of a new series contributes nothing on its own; the first failure after a restart is partly invisible. At 5 requests per second it does not matter. At very low rates it delays detection, which is one more reason low-traffic SLOs need different treatment.
LAB Write the burn-rate alerts, prove a slow burn with promtool, then watch a fast burn page ~50 MIN
YOU NEEDDocker Desktop or Docker Engine with Compose v2the ATLAS repo cloned, working in labs/observabilityprometheus/rules/slo.yml from the previous chapter's labcurl and jq

You will write prometheus/rules/slo-alerts.yml, unit-test it against five scenarios including two that take hours or days in real time, then make the live stack page in minutes and watch which window holds the alert after the fault is gone. Later chapters in this module reuse both file names, so keep them.

1. Check the SLO series are being recorded.

cd labs/observability
docker compose --profile telemetry up -d
q() { curl -sG localhost:9090/api/v1/query --data-urlencode "query=$1" | jq -r '.data.result[] | "\(.metric.slo // "-")\t\(.value[1])"'; }
q 'slo:error_budget:ratio'
q 'slo:sli_error:ratio_rate1h'
Two lines each: checkout-availability and checkout-latency, with budgets of about 0.001 and 0.01 and error ratios near 0 (the 1-hour availability ratio may still show the burn from the previous lab). If nothing prints, slo.yml is missing or not loaded: redo steps 3 and 5 of the previous chapter’s lab.

2. Write the alerts and load them. Save the file from the body of this chapter as prometheus/rules/slo-alerts.yml:

cat > prometheus/rules/slo-alerts.yml <<'EOF'
# Multiwindow, multi-burn-rate alerts, SRE Workbook ch. 5, Table 5-8
# (observability/burn-rate-alerts). Thresholds are burn rate x error budget,
# read per SLO from slo:error_budget:ratio in slo.yml.
groups:
  - name: slo-alerts
    rules:
      - alert: ErrorBudgetBurn
        expr: |
          (
              slo:sli_error:ratio_rate1h  > on(slo) (14.4 * slo:error_budget:ratio)
            and
              slo:sli_error:ratio_rate5m  > on(slo) (14.4 * slo:error_budget:ratio)
          )
          or
          (
              slo:sli_error:ratio_rate6h  > on(slo) (6 * slo:error_budget:ratio)
            and
              slo:sli_error:ratio_rate30m > on(slo) (6 * slo:error_budget:ratio)
          )
        labels:
          severity: page
        annotations:
          summary: "{{ $labels.slo }} is burning error budget fast (2% in 1h or 5% in 6h)"
      - alert: ErrorBudgetBurn
        expr: |
          (
              slo:sli_error:ratio_rate1d  > on(slo) (3 * slo:error_budget:ratio)
            and
              slo:sli_error:ratio_rate2h  > on(slo) (3 * slo:error_budget:ratio)
          )
          or
          (
              slo:sli_error:ratio_rate3d  > on(slo) slo:error_budget:ratio
            and
              slo:sli_error:ratio_rate6h  > on(slo) slo:error_budget:ratio
          )
        labels:
          severity: ticket
        annotations:
          summary: "{{ $labels.slo }} is burning error budget (10% in 1d or 3d)"
EOF
docker compose exec prometheus promtool check rules /etc/prometheus/rules/slo-alerts.yml
curl -s -X POST localhost:9090/-/reload
sleep 10
curl -s localhost:9090/api/v1/rules | jq -r '.data.groups[] | select(.name=="slo-alerts") | .rules[] | "\(.name)\t\(.labels.severity)\t\(.health)\t\(.state)"'
SUCCESS: 2 rules found, then ErrorBudgetBurn page ok inactive and ErrorBudgetBurn ticket ok inactive. If the previous lab’s burn was less than six hours ago, the ticket may already read firing: its 3-day and 6-hour windows still hold those failures. That is the long reset time the body described, not a bug.

3. Unit-test five scenarios. Create prometheus/tests/slo-alerts-test.yml. Each case feeds counters at 5 requests per second, one sample a minute, and asserts which alerts are firing at chosen times:

mkdir -p prometheus/tests
cat > prometheus/tests/slo-alerts-test.yml <<'EOF'
# promtool test rules prometheus/tests/slo-alerts-test.yml
# Synthetic gateway counters at 5 req/s (300 per minute), one sample a minute.
rule_files:
  - ../rules/slo.yml
  - ../rules/slo-alerts.yml
evaluation_interval: 1m

tests:
  # 2 h clean, then 20% of checkouts fail (FAULT_ERROR_RATE=0.2): burn rate 200.
  - name: fast burn pages in minutes
    interval: 1m
    input_series:
      - series: 'http_requests_total{job="gateway",route="/checkout",method="GET",status="200"}'
        values: '0+300x120 36240+240x59'
      - series: 'http_requests_total{job="gateway",route="/checkout",method="GET",status="502"}'
        values: '0x120 60+60x59'
    alert_rule_test:
      - eval_time: 120m
        alertname: ErrorBudgetBurn
        exp_alerts: []
      - eval_time: 123m
        alertname: ErrorBudgetBurn
        exp_alerts:
          - exp_labels: { severity: ticket, slo: checkout-availability }
            exp_annotations:
              summary: "checkout-availability is burning error budget (10% in 1d or 3d)"
      - eval_time: 126m
        alertname: ErrorBudgetBurn
        exp_alerts:
          - exp_labels: { severity: page, slo: checkout-availability }
            exp_annotations:
              summary: "checkout-availability is burning error budget fast (2% in 1h or 5% in 6h)"
          - exp_labels: { severity: ticket, slo: checkout-availability }
            exp_annotations:
              summary: "checkout-availability is burning error budget (10% in 1d or 3d)"

  # 6 h clean, 6 minutes at 20% errors, then clean again. The page stops about
  # 5 minutes after the errors do, while the 1 h ratio is still above 1.44%.
  - name: the short window resets the page
    interval: 1m
    input_series:
      - series: 'http_requests_total{job="gateway",route="/checkout",method="GET",status="200"}'
        values: '0+300x360 108240+240x5 109740+300x60'
      - series: 'http_requests_total{job="gateway",route="/checkout",method="GET",status="502"}'
        values: '0x360 60+60x5 360x60'
    alert_rule_test:
      - eval_time: 366m
        alertname: ErrorBudgetBurn
        exp_alerts:
          - exp_labels: { severity: page, slo: checkout-availability }
            exp_annotations:
              summary: "checkout-availability is burning error budget fast (2% in 1h or 5% in 6h)"
          - exp_labels: { severity: ticket, slo: checkout-availability }
            exp_annotations:
              summary: "checkout-availability is burning error budget (10% in 1d or 3d)"
      - eval_time: 372m
        alertname: ErrorBudgetBurn
        exp_alerts:
          - exp_labels: { severity: ticket, slo: checkout-availability }
            exp_annotations:
              summary: "checkout-availability is burning error budget (10% in 1d or 3d)"
    promql_expr_test:
      - expr: slo:sli_error:ratio_rate1h > bool 0.0144
        eval_time: 372m
        exp_samples:
          - labels: '{slo="checkout-availability"}'
            value: 1

  # 2 h of fast checkouts, then 20% take longer than 0.5 s
  # (FAULT_SLOW_PAYMENTS_PCT=20). The latency budget is 1%, so the burn rate is 20.
  - name: latency burn pages too
    interval: 1m
    input_series:
      - series: 'http_request_duration_seconds_bucket{job="gateway",route="/checkout",method="GET",status="200",le="0.5"}'
        values: '0+300x120 36240+240x59'
      - series: 'http_request_duration_seconds_count{job="gateway",route="/checkout",method="GET",status="200"}'
        values: '0+300x179'
    alert_rule_test:
      - eval_time: 160m
        alertname: ErrorBudgetBurn
        exp_alerts:
          - exp_labels: { severity: ticket, slo: checkout-latency }
            exp_annotations:
              summary: "checkout-latency is burning error budget (10% in 1d or 3d)"
      - eval_time: 170m
        alertname: ErrorBudgetBurn
        exp_alerts:
          - exp_labels: { severity: page, slo: checkout-latency }
            exp_annotations:
              summary: "checkout-latency is burning error budget fast (2% in 1h or 5% in 6h)"
          - exp_labels: { severity: ticket, slo: checkout-latency }
            exp_annotations:
              summary: "checkout-latency is burning error budget (10% in 1d or 3d)"

  # 6 h clean, then 1% of checkouts fail: burn rate 10. The 1 h branch never
  # fires (1% < 1.44%); the 6 h branch needs 3.6 h of it.
  - name: slow burn pages in hours
    interval: 1m
    input_series:
      - series: 'http_requests_total{job="gateway",route="/checkout",method="GET",status="200"}'
        values: '0+300x360 108297+297x300'
      - series: 'http_requests_total{job="gateway",route="/checkout",method="GET",status="502"}'
        values: '0x360 3+3x300'
    alert_rule_test:
      - eval_time: 420m
        alertname: ErrorBudgetBurn
        exp_alerts:
          - exp_labels: { severity: ticket, slo: checkout-availability }
            exp_annotations:
              summary: "checkout-availability is burning error budget (10% in 1d or 3d)"
      - eval_time: 560m
        alertname: ErrorBudgetBurn
        exp_alerts:
          - exp_labels: { severity: ticket, slo: checkout-availability }
            exp_annotations:
              summary: "checkout-availability is burning error budget (10% in 1d or 3d)"
      - eval_time: 590m
        alertname: ErrorBudgetBurn
        exp_alerts:
          - exp_labels: { severity: page, slo: checkout-availability }
            exp_annotations:
              summary: "checkout-availability is burning error budget fast (2% in 1h or 5% in 6h)"
          - exp_labels: { severity: ticket, slo: checkout-availability }
            exp_annotations:
              summary: "checkout-availability is burning error budget (10% in 1d or 3d)"

  # 3 days clean, then 0.2% of checkouts fail: burn rate 2. Never a page;
  # a ticket once the 3-day window has seen 10% of the budget go, about 36 h in.
  - name: smouldering burn opens a ticket after a day and a half
    interval: 1m
    input_series:
      - series: 'http_requests_total{job="gateway",route="/checkout",method="GET",status="200"}'
        values: '0+300x4320 1296299.4+299.4x2400'
      - series: 'http_requests_total{job="gateway",route="/checkout",method="GET",status="502"}'
        values: '0x4320 0.6+0.6x2400'
    alert_rule_test:
      - eval_time: 4500m
        alertname: ErrorBudgetBurn
        exp_alerts: []
      - eval_time: 6420m
        alertname: ErrorBudgetBurn
        exp_alerts: []
      - eval_time: 6540m
        alertname: ErrorBudgetBurn
        exp_alerts:
          - exp_labels: { severity: ticket, slo: checkout-availability }
            exp_annotations:
              summary: "checkout-availability is burning error budget (10% in 1d or 3d)"
EOF
time docker compose exec prometheus promtool test rules /etc/prometheus/tests/slo-alerts-test.yml
SUCCESS after 15 to 60 seconds: promtool has simulated about 4.5 days of rule evaluations, once a minute, against the real rule files. Read the slow-burn case against the body’s formula: 1% errors is a burn rate of 10, the 1-hour branch can never fire because 1% is under 1.44%, and the 6-hour branch needs 6 × 6 / 10 = 3.6 hours. At 560m, 3 h 20 min into the burn, only the ticket is firing; at 590m, 3 h 50 min in, the page is too. The smouldering case never pages and opens a ticket between 35 and 37 hours in.

4. Find the minute the slow burn pages. Change the slow-burn case’s eval_time: 590m to 575m and run the test again:

sed -i.bak 's/eval_time: 590m/eval_time: 575m/' prometheus/tests/slo-alerts-test.yml
docker compose exec prometheus promtool test rules /etc/prometheus/tests/slo-alerts-test.yml
mv prometheus/tests/slo-alerts-test.yml.bak prometheus/tests/slo-alerts-test.yml
FAILED, for slow burn pages in hours at time: 9h35m: exp lists the page and the ticket, got has only the ticket. The errors start at 6 h, so 3 h 35 min in, the 6-hour window is still under 0.6%. Moving the time a minute at a time finds the page at 9 h 38 min, 3 h 38 min after the errors started: the 3.6 hours the formula predicts, to the evaluation interval. The mv restores the file.

5. Make the live stack page. Fail 20% of charges and print the firing alerts every 30 seconds for eight minutes:

FAULT_ERROR_RATE=0.2 docker compose --profile telemetry up -d payments
start=$(date +%s)
for i in $(seq 16); do
  sleep 30
  printf '%4ss  ' $(( $(date +%s) - start ))
  curl -s localhost:9090/api/v1/alerts | jq -r '[.data.alerts[] | select(.labels.alertname=="ErrorBudgetBurn" and .state=="firing") | "\(.labels.slo)/\(.labels.severity)"] | if length == 0 then "none" else join("  ") end'
done
The ticket for checkout-availability appears within the first minute or two; on a young stack the 3-day window holds little clean history, so 20% errors put it over 0.1% almost at once. The page appears between about 2 and 5 minutes in: 4.3 minutes when Prometheus has at least an hour of clean history, sooner when it has less, because the 1-hour ratio is then a ratio over less data. Open localhost:9090/alerts and the page alert’s value is the 1-hour error ratio, well above 0.0144. Nothing for checkout-latency: failed checkouts are fast.

6. Stop the fault and see which window holds the page.

docker compose --profile telemetry up -d payments
sleep 360
for w in 5m 30m 1h 6h; do printf '%-4s burn rate ' $w; q "slo:sli_error:ratio_rate$w{slo=\"checkout-availability\"} / on(slo) slo:error_budget:ratio" | cut -f2; done
curl -s localhost:9090/api/v1/alerts | jq -r '.data.alerts[] | select(.labels.alertname=="ErrorBudgetBurn" and .state=="firing") | "\(.labels.slo)/\(.labels.severity)"'
The 5-minute burn rate is 0, under 14.4, so the fast branch has stopped, though the 1-hour burn rate is still well above 14.4. If Prometheus has six or more hours of clean history, the 6-hour burn rate is under 6 and the page has cleared: about 5 minutes of reset, as the unit test showed. On a younger stack the 6-hour ratio is computed over less data and sits above 6, and the 30-minute burn rate is above 6 until the burst leaves that window, so the page stays up for up to 30 minutes through the second branch. That is the second branch’s reset time, and a reason lab numbers differ from production ones. The ticket stays either way.
Delete the two short-window lines and their and from the page rule, so it reads slo:sli_error:ratio_rate1h > on(slo) (14.4 * slo:error_budget:ratio) or slo:sli_error:ratio_rate6h > on(slo) (6 * slo:error_budget:ratio), the Workbook’s fifth design. promtool check rules passes, and the fast-burn, slow-burn and latency tests still pass: detection did not change. Only the short window resets the page fails, at 6 h 12 min, with the page still firing six minutes after the errors stopped. Without the short window the page fires for most of the next hour, while the person who fixed the problem watches it and wonders whether the fix worked. Restore the lines before the next chapter.
DECIDE

An internal admin API serves about 200 requests an hour and has a 99.9% availability SLO with the same burn-rate alerts as checkout. It has paged four times this month, each time for three or four failed requests in an hour that the users retried successfully. Nobody has ever acted on one of these pages. What do you change?

READING
  1. BOOK
    The Site Reliability Workbook, chapter 5: Alerting on SLOs Steven Thurgood et al., 2018

    The source of every number in this chapter: the four properties, the six designs with their pros and cons, the burn-rate formulas, the recommended windows, and the sections on low traffic and extreme targets. Read the Prometheus rules in it alongside the ones you wrote. Read: the whole chapter; the six approaches and Table 5-8 are the core.

  2. DOC
    Prometheus: alerting rules

    What for, keep_firing_for, labels and annotations do, how alert state moves from inactive to pending to firing, and the ALERTS series. Short; read it once before writing any alert.

  3. DOC
    Prometheus: unit testing for rules

    The full test file format: expanding series notation, alert_rule_test, promql_expr_test, and how eval_time and evaluation_interval interact. The examples at the bottom are the quickest way in.

  4. DOC
    Prometheus querying: operators

    How comparison operators filter, how on() matching works, and how and and or match on label sets while ignoring the metric name. That is everything the alert expressions rely on.

  5. DOC
    Alertmanager configuration

    Routing on labels such as severity, and the inhibit_rule fields that mute the ticket while the page fires. Skip the receiver integrations until you need one.

  6. CODE
    Sloth Xabier Larrakoetxea

    Generates exactly this style of recording rules and multiwindow, multi-burn-rate alerts from a short SLO spec. Read its generated output to compare with your hand-written files, then decide whether a generator is worth it for your number of SLOs.

  7. CODE
    Pyrra

    Another open-source SLO tool for Prometheus, with a UI that shows budgets and burn rates per SLO. Useful to see how the same rules look as a product rather than as YAML.

All companies and people in these examples are fictional. Any resemblance to a real business or person is unintended.

RECALL CARDS Tap to flip. They join your review deck when you mark the lesson complete.
NEXT: Alert design: symptoms not causes, and the page vs ticket line →