Observability and SREVol. 9 · Part IX
0 / 0

Shelves / Observability and SRE

OB·102

SLIs, SLOs, SLAs and Error Budgets

Service level management from first principles: SLIs as ratios of good to valid events, choosing indicators for request, pipeline and storage systems, where to measure, setting availability and latency targets from user journeys, SLOs versus SLAs, error budgets and error budget policies, burn rate and its arithmetic, multi-window multi-burn-rate alerting, dependency and composite SLOs, and implementing it all with Prometheus recording rules, Sloth, Pyrra and OpenSLO.

28 topics · ~17 min read · 30-question quiz
Updated Suggest a correction

Start here: how reliable is reliable enough?

Measure what users experience, as a ratio

Ask "what fraction of requests went well?". For 2,000 orders sent to the tiffin service:

Text
requests 1991, failed 18, successful under 500 ms 1831            (Prometheus, last 10 minutes)
availability SLI  = good / valid = 1 − 18/1991            = 99.09%
latency SLI       = successful and under 500 ms / successful = 92.80%

(The service's own log counted 2,000 requests and 19 failures; Prometheus's increase() extrapolates from samples, so it's close but not exact. SLIs are estimates, and that's fine.)

Each measure is a service level indicator (SLI). A service level objective (SLO) is a target for one over a window: "99.5% of orders succeed, measured over the last 30 days". An SLA is a contract that promises a (looser) target to customers with penalties.

The error budget: the failure you're allowed

An SLO of 99.5% means 0.5% of requests may fail. That 0.5% is the error budget. At 1,000 orders a minute, a 30-day budget is 216,000 failed orders. You can spend it on risky deploys, experiments and migrations; when it runs low you slow down and fix reliability. It turns "are we reliable enough?" from an argument into a number.

Burn rate says how fast the budget is going: the current error ratio divided by the budget ratio. The tiffin service's 0.91% failures against a 0.5% budget is a burn rate of 1.8: if it continued, the month's budget would be gone in about 17 days. Its latency SLI against a 95% target burns at 1.4 (the slow biryani query from Start Here).

Alert on burn rate, not on every blip

promtool replayed five traffic patterns through two alerting rules for a 99.9% SLO: a naive "page if the 5-minute error ratio is over 1%", and the SRE Workbook's multi-window burn-rate alert:

Text
                                              naive 5-minute alert      burn-rate page
A) 10% of requests fail for 2 hours           fires after 1 min          fires after 9 min (2.1% of budget used)
C) a 10-minute blip of 3% failures            pages                      doesn't page
E) two normal days with short error blips     pages 12 times             never pages

The naive alert is fast but cries wolf twelve times in two days for blips that used a fraction of a percent of the budget; on-call engineers learn to ignore it. The burn-rate alert pages only when a meaningful share of the budget is at risk, still within minutes for a real outage.

How deep to go in SLIs, SLOs, SLAs and error budgets

Volume 17 defines six mastery levels. For this chapter they look like this; the chapter aims at L3 everywhere, and its lab at L4.

Level What you can do
L1 Explain SLI, SLO, SLA, error budget and burn rate
L2 Compute SLIs and budgets from metrics for one service
L3 Choose user-centred SLIs and targets; write burn-rate recording and alerting rules
L4 Test and tune SLO alerts; diagnose noisy or late alerts and misleading SLIs
L5 Design SLOs across a system of services, with error budget policies agreed by product
L6 Run an SLO programme: tooling, reviews, budget-driven planning across an organisation

The vocabulary

Term Meaning Example
SLI (service level indicator) A measurement of some aspect of service quality, ideally expressed as a ratio of good events to valid events Proportion of checkout requests that return non-5xx in under 500 ms
SLO (service level objective) A target for an SLI over a time window 99.9% of checkout requests good, over a rolling 28 days
SLA (service level agreement) A contract with customers that includes consequences (service credits, penalties) when missed 99.5% monthly availability, or 10% credit
Error budget The amount of unreliability the SLO allows: 1 − SLO 0.1% of requests over 28 days may be bad

The core idea from Google's SRE practice: 100% is the wrong reliability target for almost everything. Users can't tell 99.99% from 100% when their own Wi-Fi and phones are less reliable than that, and every extra nine costs dramatically more (more redundancy, slower releases). Choose a target that keeps users happy, then spend the remaining budget on shipping features and taking risks.

SLIs

Good events over valid events

The most useful SLI form is a ratio:

SLI = good events / valid events × 100%

  • It's naturally between 0 and 100%.
  • It works the same way for availability, latency, freshness and correctness.
  • "Valid" lets you exclude events that shouldn't count (health checks, requests rejected for bad input or authentication, traffic from load tests).

Choosing SLIs by system type

System type Typical SLIs
Request/response (APIs, web) Availability: proportion of valid requests served successfully. Latency: proportion of requests faster than a threshold. Quality: proportion served without degradation (not from a fallback)
Data pipelines / batch Freshness: proportion of time (or of records) where data is newer than X minutes. Correctness: proportion of records processed correctly. Coverage: proportion of input processed. Throughput for big jobs
Storage Durability (data retrievable), availability of reads and writes, latency of operations
Streaming / async End-to-end delivery latency (event created → consumed), lag within bounds, proportion of messages processed without dead-lettering

Focus on user journeys, not components: "user can add to cart", "checkout completes", "search returns results", "a payment notification arrives within 1 minute". A database's CPU isn't an SLI; checkout success is.

SLI specification versus implementation

  • Specification: what you want to measure, in user terms. "Proportion of home page loads that render the product list in under 2 s."
  • Implementation: how you actually measure it. Each choice has trade-offs:
Measurement point Pros Cons
Application/server metrics Easy, detailed, per endpoint Misses failures before the app (LB, DNS, network); "the server thinks it's fine"
Load balancer / gateway logs or metrics Captures requests the app never saw (timeouts, 502s) Still server-side; no client experience
Synthetic probes (blackbox exporter, Checkly, cloud synthetics) Measures from outside; works with zero traffic A tiny sample of artificial traffic; can miss real-user paths
Real user monitoring / client telemetry What users actually experience (including network, rendering) Noisy, delayed, needs client instrumentation; affected by users' own networks

A common approach: SLIs from load balancer or gateway metrics (closest to users while still reliable and complete), complemented by synthetic probes for low-traffic and "is it up at all" checks, and RUM for frontends.

Latency SLIs: thresholds, not averages

Express latency as a ratio against a threshold: "proportion of requests completed in < 300 ms" rather than "p99 < 300 ms". The ratio form:

  • composes with error budgets (each slow request consumes budget, like an error),
  • avoids the problems of aggregating percentiles (chapter 100),
  • is computed directly from histogram buckets: rate(duration_bucket{le="0.3"}[w]) / rate(duration_count[w]), which is why you put a bucket boundary at the threshold.

Use multiple latency SLIs if needed: 90% < 100 ms (typical experience) and 99% < 1 s (tail).

SLOs

Setting targets

An SLO = SLI + target + window:

  • Rolling windows (last 28 or 30 days) are best for engineering decisions: they always reflect recent experience. 28 days covers four of each weekday.
  • Calendar windows (per month or quarter) align with business reporting and SLAs.

How to choose the target:

  1. Start from what users need and what they experience today (look at historical SLI values).
  2. Don't promise more than you deliver now; tighten over time if users need it.
  3. Mind dependencies: you can't be more available than a hard dependency you have no fallback for (Vol. 7 ch. 85 arithmetic).
  4. Different journeys, different targets: checkout 99.95%, recommendations 99%, internal reporting 99%.
  5. Fewer, better SLOs: a handful per service that map to user journeys.

What the nines mean for a 28-day window:

SLO Error budget Allowed "bad time" (if all-or-nothing)
99% 1% ~6 h 43 min
99.5% 0.5% ~3 h 22 min
99.9% 0.1% ~40 min
99.95% 0.05% ~20 min
99.99% 0.01% ~4 min

With request-based SLIs, the budget is a number of bad requests: at 10 million requests per 28 days and 99.9%, you may have 10,000 bad requests.

SLAs

An SLA is a business and legal promise, so:

  • It's looser than the internal SLO (if your SLO is 99.9%, your SLA might be 99.5%), so you get warned and act before you owe credits.
  • It defines measurement precisely (what counts as downtime, exclusions like scheduled maintenance and customer-caused issues, how claims work).
  • Many services have SLOs without SLAs (internal services, free tiers).

Cloud provider SLAs (Vol. 7 ch. 85) are financial commitments, not guarantees; your design must meet your SLOs.

Error budgets

The budget as a decision tool

The error budget turns reliability into a shared, quantitative currency between product and engineering:

  • Budget remaining → ship features, run experiments, do risky migrations, deploy on Friday if you want.
  • Budget exhausted → prioritise reliability: freeze risky changes, fix the top causes of budget burn, invest in tests, rollbacks and capacity.

This replaces endless arguments ("are we reliable enough?") with data.

Error budget policy

Write the consequences down before they're needed, agreed by engineering and product leadership:

Text
Error budget policy: checkout service (SLO: 99.9% good requests over rolling 28 days)

- Budget > 50% remaining: normal development velocity.
- Budget 25–50%: postmortems required for any single incident consuming > 10% of budget;
  reliability items prioritised in the next sprint.
- Budget < 25%: only low-risk changes (bug fixes, reliability work, security patches) may deploy;
  feature launches need explicit approval from the engineering director.
- Budget exhausted: feature freeze until the 28-day SLI recovers above the SLO,
  except security fixes and changes that improve reliability.
- If a single incident consumes > 20% of the budget: mandatory postmortem with action items
  tracked to completion.
- Disputes are escalated to the CTO.

Exceptions: budget consumed by dependencies outside your control or by load tests, or known external events, may be excluded by agreement, but be careful: users don't care whose fault it was.

Burn rate

Definition

Burn rate = how fast you're consuming the error budget relative to the rate that would exactly exhaust it at the end of the window:

burn rate = observed error ratio / (1 − SLO)

  • Burn rate 1: you'll use exactly 100% of the budget over the window.
  • Burn rate 2: budget gone in half the window (14 days of a 28-day window).
  • Burn rate 14.4 over 1 hour: you've consumed 14.4 / (28 × 24) ≈ 2.1% of a 28-day budget in that hour (2% of a 30-day budget, which is where the commonly quoted number comes from).

Example: SLO 99.9% (budget 0.1%). In the last hour, 1.44% of requests failed. Burn rate = 1.44 / 0.1 = 14.4.

100%0%day 28014 budget burn 1 burn 2 burn 14.4 → ~2 days fast burn → page nowslow burn → ticket
Error budget burn over a 28-day window. A steady burn rate of 1 uses the whole budget exactly by the end; a burn rate of 14.4 sustained would exhaust it in under two days. Alerts fire when the burn rate over a window implies a significant share of budget will be consumed soon.

Multi-window, multi-burn-rate alerts

Naive SLO alerts fail one of two ways: alerting on any error-ratio spike is noisy; alerting only when the whole 28-day budget is gone is far too late. The approach from Google's SRE Workbook is to alert on burn rate over a long window, confirmed by a short window (so the alert stops soon after the problem stops):

Severity Long window Short window Burn rate Budget consumed when it fires Action
Page 1 h 5 min 14.4 ~2% Wake someone up
Page 6 h 30 min 6 ~5% Urgent
Ticket 3 days 6 h 1 ~10% Fix in working hours

(Percentages are for a 30-day window, as in the Workbook; with 28 days they're slightly higher.) The alert fires when both windows exceed the threshold:

  • the long window ensures enough budget has really been consumed (significance, few false positives);
  • the short window ensures the problem is still happening (fast reset after recovery).
YAML
# Prometheus alerting rules for SLO 99.9% (error budget 0.001), using recorded error ratios per window
groups:
- name: checkout-slo
  rules:
  - alert: CheckoutErrorBudgetFastBurn
    expr: |
      (
        job:checkout_error_ratio:rate1h > (14.4 * 0.001)
        and
        job:checkout_error_ratio:rate5m > (14.4 * 0.001)
      )
      or
      (
        job:checkout_error_ratio:rate6h > (6 * 0.001)
        and
        job:checkout_error_ratio:rate30m > (6 * 0.001)
      )
    labels: { severity: page }
    annotations:
      summary: "Checkout is burning its error budget fast"
      runbook_url: "https://runbooks.acme.dev/checkout/slo-burn"
      dashboard: "https://grafana.acme.dev/d/checkout-slo"
  - alert: CheckoutErrorBudgetSlowBurn
    expr: |
      job:checkout_error_ratio:rate3d > (1 * 0.001)
      and
      job:checkout_error_ratio:rate6h > (1 * 0.001)
    labels: { severity: ticket }
YAML
# The recording rules behind it (one per window); the latency SLI works the same way with bucket ratios
- record: job:checkout_error_ratio:rate5m
  expr: |
    sum(rate(http_server_request_duration_seconds_count{service="checkout", status_code=~"5.."}[5m]))
    / sum(rate(http_server_request_duration_seconds_count{service="checkout"}[5m]))
- record: job:checkout_slow_ratio:rate5m              # latency SLI: requests slower than 300 ms
  expr: |
    1 - (
      sum(rate(http_server_request_duration_seconds_bucket{service="checkout", le="0.3"}[5m]))
      / sum(rate(http_server_request_duration_seconds_count{service="checkout"}[5m]))
    )
# …and the same expressions for 30m, 1h, 6h, 3d windows

Low-traffic services need care: at 10 requests per hour, one failure is a 10% error ratio. Options: longer windows, minimum request counts in alert expressions, synthetic traffic to raise volume, or grouping several low-traffic endpoints into one SLO.

Generating SLO rules

Writing all those recording and alerting rules by hand is error-prone. Tools generate them from a short spec:

  • Sloth: Prometheus SLO generator (YAML spec → recording rules, multi-window alerts, Grafana dashboards).
  • Pyrra: Kubernetes-native SLO CRDs with a UI.
  • OpenSLO: a vendor-neutral YAML specification for SLOs.
  • Managed: Google Cloud SLO monitoring, Datadog, Dynatrace, New Relic, Nobl9, Grafana SLO, Honeycomb, CloudWatch Application Signals SLOs.
YAML
# Sloth spec: generates all recording rules and multi-window multi-burn-rate alerts
version: "prometheus/v1"
service: "checkout"
labels: { team: payments }
slos:
  - name: "requests-availability"
    objective: 99.9
    description: "Checkout requests succeed (non-5xx)."
    sli:
      events:
        error_query: sum(rate(http_server_request_duration_seconds_count{service="checkout",status_code=~"5.."}[{{.window}}]))
        total_query: sum(rate(http_server_request_duration_seconds_count{service="checkout"}[{{.window}}]))
    alerting:
      name: CheckoutAvailability
      page_alert: { labels: { severity: page } }
      ticket_alert: { labels: { severity: ticket } }

SLOs in a system of services

Dependencies and composite SLOs

  • A service's SLO is bounded by its hard dependencies' reliability: if checkout synchronously needs payments (99.9%) and inventory (99.9%) with no fallback, checkout can't reliably hit 99.95%. Options: fallbacks, caching, asynchronous designs, or negotiating stronger dependency SLOs.
  • Internal platform teams publish SLOs (for databases, queues, the Kubernetes platform) so consumers can design around them.
  • Composite SLOs combine several SLIs (all steps of a user journey) into one view for leadership, while teams keep per-service SLOs for operations.

SLOs and engineering practice

  • Alert on SLOs (symptoms users feel) for paging; use cause-based alerts (disk filling, certificate expiring) as tickets or for clear leading indicators (chapter 103).
  • Review SLOs regularly (quarterly): are they too tight (constant firefighting, budget always exhausted though users are happy) or too loose (users complain though SLOs are met)?
  • Use budgets in planning: reliability work gets prioritised by budget consumption, not by whoever shouts loudest.
  • Report: an SLO dashboard per service showing SLI vs target, budget remaining, burn rate, and the incidents and deploys that consumed budget.

Lab: testing SLO alerts before production does

Prometheus 3.15's promtool test rules evaluates recording and alerting rules against input series you define, minute by minute, exactly as Prometheus would. The rules are the multi-window, multi-burn-rate rules from this chapter for a 99.9% availability SLO (30-day budget), plus a naive comparison alert. The traffic is simulated (1,000 requests a minute, with a chosen error ratio per minute) after 3 days of clean history, so the long windows behave as they would in production. Detection times are exact to the minute (10 minutes for scenario D, 2 for E).

The rules under test

YAML
- record: job:checkout_error_ratio:rate5m        # and the same for 30m, 1h, 6h, 3d
  expr: sum(rate(http_requests_errors_total[5m])) / sum(rate(http_requests_total[5m]))
- alert: CheckoutErrorBudgetFastBurn             # page
  expr: (job:checkout_error_ratio:rate1h > 14.4 * 0.001 and job:checkout_error_ratio:rate5m > 14.4 * 0.001)
     or (job:checkout_error_ratio:rate6h > 6 * 0.001 and job:checkout_error_ratio:rate30m > 6 * 0.001)
- alert: CheckoutErrorBudgetSlowBurn             # ticket
  expr: job:checkout_error_ratio:rate3d > 0.001 and job:checkout_error_ratio:rate6h > 0.001
- alert: CheckoutErrorRateHigh                   # the naive alternative
  expr: job:checkout_error_ratio:rate5m > 0.01

A promtool test case looks like this (the lab generates one per scenario, with thousands of evaluation points):

YAML
rule_files: [rules.yml]
evaluation_interval: 1m
tests:
  - interval: 1m
    input_series:
      - {series: http_requests_total,        values: "0+1000x4500"}
      - {series: http_requests_errors_total, values: "0+0x4380 100+100x119"}
    alert_rule_test:
      - eval_time: 3d1h9m
        alertname: CheckoutErrorBudgetFastBurn
        exp_alerts: [{exp_labels: {severity: page}}]

Results

Text
A) 10% of requests fail for 2 hours (burn rate 100)
   CheckoutErrorRateHigh        fired after    1 min (budget used  0.2%), 1 episode(s), stopped    4 min after recovery
   CheckoutErrorBudgetFastBurn  fired after    9 min (budget used  2.1%), 1 episode(s), stopped   28 min after recovery
   CheckoutErrorBudgetSlowBurn  fired after   44 min (budget used 10.2%), 1 episode(s), stopped  121 min after recovery
B) 2% fail for 3 hours (burn rate 20)
   CheckoutErrorRateHigh        fired after    3 min (budget used  0.1%), 1 episode(s), stopped    2 min after recovery
   CheckoutErrorBudgetFastBurn  fired after   44 min (budget used  2.0%), 1 episode(s), stopped   21 min after recovery
   CheckoutErrorBudgetSlowBurn  never fired
C) a 10-minute blip of 3% failures
   CheckoutErrorRateHigh        fired after    3 min (budget used  0.2%), 1 episode(s), stopped    4 min after recovery
   CheckoutErrorBudgetFastBurn  never fired
   CheckoutErrorBudgetSlowBurn  never fired
D) a slow leak: 0.3% fail, continuously for 3 days (burn rate 3)
   CheckoutErrorRateHigh        never fired
   CheckoutErrorBudgetFastBurn  never fired
   CheckoutErrorBudgetSlowBurn  fired after 1450 min (budget used 10.1%), 1 episode(s)
E) normal life: 0.05% errors, plus 1.5% for 6 minutes every 4 hours, for 2 days
   CheckoutErrorRateHigh        fired after    4 min (budget used  0.1%), 12 episode(s)
   CheckoutErrorBudgetFastBurn  never fired
   CheckoutErrorBudgetSlowBurn  never fired

What the results teach

  • The thresholds encode budget consumed. The page fired when about 2% of the month's budget had gone (A and B, whatever the error rate), and the ticket at about 10% (A and D). That's the design: 14.4 × 1 hour ÷ 720 hours ≈ 2%; 1 × 3 days ÷ 30 days = 10%. Higher error rates are detected faster (9 minutes at 10% errors, 44 at 2%) because the budget goes faster.
  • The naive alert is fast and useless. It caught every real problem first, but it also fired twelve times in two healthy days (E) and on the harmless blip (C), and it never noticed the slow leak (D), which quietly consumed 10% of the budget a day. A page that fires twice a day for nothing trains people to ignore pages.
  • The short window controls reset. The fast-burn page stopped 21–28 minutes after recovery, mostly because of the 6-hour/30-minute pair; without short windows, a 1-hour or 6-hour window would keep paging for hours after the fix.
  • The slow leak needs a ticket, not a page: a burn rate of 3 leaves days to react, so the response is a ticket worked in office hours.

A pitfall found while building this lab

The first version of the simulation started the incident with only one hour of history. Every alert, including the 3-day slow-burn ticket, fired within 2–5 minutes, because rate(x[3d]) over a series that's only an hour old is computed over the hour that exists. The same thing happens in production after a new service launches, after a metric is renamed, or when a label changes and creates fresh series: long-window SLO alerts behave like short-window ones until enough history exists. Guard new SLOs with a minimum-age or minimum-traffic condition (for example and sum(increase(http_requests_total[3d])) > 100000), or wait before enabling paging.

A live SLI from the tiffin service

Text
requests 1991, failed 18, successful under 500 ms 1831
availability SLI 99.09%  vs SLO 99.5%: burn rate 1.8
latency SLI (successful requests under 500 ms) 92.80%  vs SLO 95%: burn rate 1.4

Both budgets are burning; the latency one is caused by the slow biryani stock query (Start Here) and would be the first item in an error-budget review.

Try it yourself

  1. Change the SLO to 99.99% in the rules and rerun scenario E. How many pages now?
  2. Add a minimum-traffic guard to the fast-burn alert and simulate a quiet night with 10 requests a minute and one failure.
  3. Write the latency SLO rules (bucket le="0.5" ratio) and a promtool test for a latency regression.

Revision sheet: SLIs, SLOs, SLAs and error budgets

Key ideas

  • SLI = good events / valid events; measured as close to the user as possible.
  • SLO = SLI target over a window (rolling 28/30 days for engineering, calendar for reporting); SLA = contract, looser than the SLO.
  • Error budget = 1 − SLO; an error budget policy decides what happens as it's consumed.
  • Burn rate = error ratio / budget ratio; multi-window, multi-burn-rate alerts page on fast burn and ticket on slow burn.
  • Composite SLOs across dependencies; SLOs per user journey, few and meaningful.
  • Tools: Sloth, Pyrra, OpenSLO, managed SLO features; test rules with promtool.

Numbers to remember

  • 28-day all-or-nothing budgets: 99% ≈ 6 h 43 min, 99.9% ≈ 40 min, 99.99% ≈ 4 min.
  • Workbook alerts (30-day window): 14.4× over 1 h/5 min (2% budget), 6× over 6 h/30 min (5%), 1× over 3 d/6 h (10%).
  • Lab: page after 9 min at 10% errors, 44 min at 2%; naive alert 12 false pages in 2 days.

Pitfalls

  • SLIs measured where users aren't (server CPU instead of request success).
  • Too many SLOs; 100% targets; SLOs nobody acts on.
  • Alerting on raw error rate.
  • Low-traffic services and new series breaking long-window maths.
  • Excluding "not our fault" failures users still felt.

Glossary

  • Valid events: the denominator after exclusions.
  • Rolling window: last N days, always moving.
  • Error budget policy: agreed consequences of budget levels.
  • Fast burn / slow burn: high burn rate over short windows / modest burn rate over long ones.
  • Composite SLO: combination of dependent services' SLOs for a journey.