How-To Guide

How to Implement Error Budgets and SLOs

Define an SLO and its error budget: pick an SLI, set a target, measure the budget, and use the burn rate to alert and to decide.

On this page

  1. Introduction
  2. Pick an SLI that reflects the user
  3. Set an achievable target and the budget
  4. Measure and alert on the burn rate
  5. Use the budget to decide
  6. Test the budget measurement and the alert
  7. Common pitfalls
  8. Conclusion

Introduction

Reliability is a trade against velocity: deploying more changes risks more errors, and being perfectly reliable means not changing. An SLO makes that trade explicit. It sets a target for the user experience over a window, such as 99.9% of requests succeed in a month, and the error budget is the failure the target allows. The budget is a number the team manages: spend it on changes while it is healthy, and slow down when it is exhausted.

This tutorial covers picking an SLI, setting a target and a budget, measuring the burn rate and alerting on it, and using the budget to decide about changes. The examples use metrics and alert rules, and the concept applies to any service.

Pick an SLI that reflects the user

The service level indicator is the measurement the target applies to, and it should reflect what the user experiences. For a request-driven service, the fraction of successful requests (excluding the client’s own errors) and the fraction of fast requests are the common ones. A good SLI is measured at the boundary the user sees, so it reflects their experience rather than an internal proxy.

Choose the SLI the user cares about. If the user experiences an error when a request fails, the success fraction is the SLI; if the user experiences slowness, the latency target is the SLI. Measure it from the requests, not from an aggregate that can hide a subset. A percentile per endpoint is often better than a single average, because the average hides the slow tail the users feel.

# SLI: the fraction of successful requests (excluding client 4xx)
sum(rate(http_requests_total{status!~"4.."}[5m])) - sum(rate(http_requests_total{status=~"5.."}[5m]))
  / sum(rate(http_requests_total{status!~"4.."}[5m]))

# SLI: the fraction of fast requests (under 300ms)
sum(rate(http_request_duration_seconds_bucket{le="0.3"}[5m])) / sum(rate(http_request_duration_seconds_count[5m]))

Set an achievable target and the budget

Set the target from what the users need and the service can achieve, not from an aspiration. A target of 99.9% over a month allows about forty-three minutes of full unavailability, which is the budget. A target of 99.99% allows about four minutes, which is far harder and may require a design change. Pick the target the service can meet and the user needs.

The budget is one minus the target, expressed in the same unit as the SLI and over the same window. Track the budget consumed, the difference between the allowed failure and the actual failure. The budget is the number the team manages: a healthy budget means room for risky changes, and an exhausted one means the reliability work takes priority.

# over a 30-day window at 99.9%: the error budget is 0.1% of requests
# consumed = the actual failures in the window
error_budget_remaining = 1 - (actual_failures / allowed_failures)

Measure and alert on the burn rate

The burn rate is how fast the budget is spent relative to the rate that would exhaust it exactly over the window. A burn rate of one spends it exactly, a rate of ten exhausts it in a tenth of the window. Alert on a fast burn, so a severe problem pages quickly, and a slower burn is a ticket, which avoids paging on a slow degradation.

Use multiple windows for the burn alert: a short window to catch a fast burn and a long window to confirm, so a brief but severe event pages and a sustained moderate one still pages without the short window firing on noise. The burn rate ties the alert to the budget, so the alert fires when the user experience is actually at risk, not on a cause metric.

# fast burn: 2% of the monthly budget in 1 hour -> page
(sum(rate(http_requests_total{status=~"5.."}[1h])) / sum(rate(http_requests_total[1h]))) > 14.4 * 0.001

# slow burn: 10% of the budget in 6 hours -> ticket
(sum(rate(http_requests_total{status=~"5.."}[6h])) / sum(rate(http_requests_total[6h]))) > 6 * 0.001

Use the budget to decide

The budget turns a policy question into arithmetic. While the budget is healthy, the team can spend it on risky changes, because the budget exists to be spent. When it is exhausted, the team slows the risky changes and prioritizes the reliability work. This removes the argument about whether to release, because the budget answers it.

Record the budget review in a regular meeting, so the trend and the decisions are visible. A budget that is always exhausted means the target is too strict or the service is under-invested, and the review surfaces that. A budget that is never dented may mean the target is too loose to be meaningful. The review keeps the target honest.

Test the budget measurement and the alert

Test the SLI computation by feeding requests that succeed and fail and asserting the SLI matches, including a client error that should be excluded. Test the burn-rate alert by driving failures at a rate that should page and one that should not, so the window and the threshold are checked. Test that the budget remaining crosses zero when the failures exceed the allowed.

# drive 1000 requests with 5 failures: assert the SLI and the budget match
node -e '
// 995 successes / 1000 -> SLI 0.995; at a 0.999 target the budget is over-consumed
// assert the burn alert would fire for this rate over the window
'

Common pitfalls

An SLI that measures an internal proxy rather than the user experience, a target too strict to meet or too loose to matter, alerting on a cause instead of the burn rate, no window on the burn so it fires on noise, and setting the budget but never using it to decide are the recurring mistakes. A user-facing SLI, an achievable target, burn-rate alerts with multiple windows, and a budget review that decides address them.

Conclusion

An SLO and its error budget make reliability a number to manage. Pick a user-facing SLI, set an achievable target and its budget, measure the burn rate and alert on a fast and a slow burn, and use the budget to decide about risky changes. Self-check by driving failures and asserting the SLI, the budget, and the burn alert match. Then the reliability trade is explicit and decided by the budget, not by argument.

Sources: Google SRE: Service level objectives, Google SRE: Alerting on SLOs, The SLO and error budget concept (SRE workbook).

FAQ

What is an SLO?
A service level objective is a target for a service level indicator over a window, such as 99.9% of requests succeed in a calendar month. It is a commitment for the user experience, and the error budget is the failure the target allows, which makes reliability a number to manage rather than a slogan.
What is burn rate?
It is how fast the error budget is being consumed relative to the rate that would exactly exhaust it over the window. A burn rate of one spends the budget exactly over the window; a rate of ten exhausts it in a tenth of the window, which is a fast burn that pages.

Related Examples