Observability, SLOs and error budgets
Logs, metrics and traces show what your system does. SLOs and error budgets tell you when to act.
Updated since you finished it. We changed this lesson after you marked it done. Your progress is kept.
What broke
Meera's team runs the checkout API for an online shop. Their dashboard has 40 graphs. On Tuesday evening, every graph looks fine. Average latency is 120 ms. CPU is at 45%.
At the same time, one in ten customers cannot pay. A new release broke payments for one card type. Those requests fail fast, so they even pull the average latency down.
Nobody is paged. The team gets 200 alerts a week about CPU and disk, so they have learned to ignore the alert channel. The problem is found the next morning, from angry messages to support.
The team had a lot of data, but no clear answer to one question: "Are our users getting what they need right now?" (This story is made up, but the pattern is common.)
It happens for real
Roblox · 28 Oct 2021Roblox outage: 73 hours down after Consul brokeRoblox was fully down for most of 73 hours, and players came back in steps only on the fourth day. Slack · 4 Jan 2021Slack outage: post-holiday traffic overloaded a cloud network linkOn the first work day of 2021, Slack was down and then slow for about three and a half hours. All incidents tagged “dependencies”The idea in simple words
Observability means you can understand what your system is doing from the data it sends out. Most of that data comes in three kinds. OpenTelemetry lists these three, plus other signals such as baggage, which carries context between them 1:
- Metrics: numbers measured over time, like requests per second or error rate. Cheap to keep, good for graphs and alerts.
- Logs: a record of one event, like "payment 7f3a failed: card declined". Rich in detail, but large.
- Traces: the path of one request through many services. A trace is made of spans, one for each step, with its timing.
Data alone does not tell you when to act. For that you need a target that matches what users feel:
- An SLI (service level indicator) is a measure of service, best written as good events ÷ total events 6. In practice, count only valid events: leave out calls like health checks. For example: the share of checkout requests that succeed in under 500 ms.
- An SLO (service level objective) is the target for that SLI over a time window. For example: 99.9% over a rolling 4 weeks 6. The alerting maths below uses a 30-day window instead, as the alerting chapter does 7.
- An SLA (service level agreement) is a contract with customers that has a penalty, often money, if you miss it 3.
The error budget is the part you are allowed to fail: 100% minus the SLO 6. With a 99.9% SLO and 1 million requests, you can fail 1,000 of them.
How it works
Availability maths: the nines
Each extra "nine" cuts the allowed downtime by 10 5:
- 99%: about 7.2 hours a month.
- 99.9%: about 43 minutes a month.
- 99.99%: about 4.3 minutes a month.
- 99.999%: about 26 seconds a month.
Services that depend on each other multiply. If checkout needs three services in a row, each 99.9%, the best it can do is 0.999 × 0.999 × 0.999 ≈ 99.7%. This assumes they fail independently. Two copies in parallel help: if each copy is 99% and they really fail independently, both are down only 0.01 × 0.01 = 0.01% of the time. In real life, copies often fail together, for example after one bad config change.
What to measure
Google's SRE book suggests four golden signals for any service: latency, traffic, errors and saturation (how full the service is) 2. It also warns that averages hide slow requests. A service with an average latency of 100 ms can still have 1% of requests take 5 seconds 2. So use percentiles, like p99, in your SLIs.
Burn-rate alerts
The burn rate is how fast you spend the error budget, compared with the speed that would use it up exactly at the end of the window 7. At burn rate 1, the budget lasts 30 days. At burn rate 10, it is gone in 3 days 7.
Step through a bad deploy and see how a burn-rate alert reacts. Use Next and Back, or the ← and → keys.
- The checkout SLO is 99.9% of requests succeed over 30 days. With about 100 million requests in that time, the error budget is 0.1%: 100,000 failed requests.
- On a normal day, 0.05% of requests fail. That is half the allowed rate, so the burn rate is 0.5. At this speed the budget would last 60 days. No alert.
- A bad deploy makes 1.44% of requests fail. The burn rate is 1.44 ÷ 0.1 = 14.4. If nothing changes, the whole 30-day budget is gone in about 2 days.
- After about an hour, the burn rate is at least 14.4 over the last hour and over the last 5 minutes. Both windows agree, so the alert pages the on-call engineer. That hour used 2% of the budget, about 2,000 errors.
- The engineer rolls back. Errors drop, the 5-minute window falls below 14.4 and the alert stops within minutes. The incident cost only about 2% of the budget, so the team can keep shipping after they fix the bug.
The Site Reliability Workbook recommends three alerts for a 99.9% SLO 7:
- Page if the burn rate is above 14.4 over the last hour and the last 5 minutes. That is 2% of the 30-day budget in one hour.
- Page if it is above 6 over the last 6 hours and the last 30 minutes. That is 5% of the budget.
- Open a ticket if it is above 1 over the last 3 days and the last 6 hours. That is 10% of the budget.
The long window proves the problem is real. The short window makes the alert stop a few minutes after the problem stops 7.
Trade-offs
| Approach | Catches real user pain? | Noise | Use it when |
|---|---|---|---|
| Alert on causes (CPU, disk, memory) | No Users can suffer while CPU is fine. | High. Many alerts need no action. | Only as tickets or dashboards, to help find a cause. |
| Alert on any error | Yes , but too early. | Very high. Every short error pages someone. | Almost never for paging. |
| Simple SLO threshold (error rate above 0.1% for 10 minutes) | Yes | Medium. Short spikes can still page. | A first step, while you learn your traffic. |
| Multiwindow, multi-burn-rate SLO alerts | Yes Fast for big outages, slower for small, steady error rates. | Low. | Most user-facing services, once SLOs exist. |
Simple rule: page a human only for symptoms that users feel. Keep cause metrics for debugging 2.
At work: how a senior uses this
- Start from the user's journey: "Can a customer pay?" Write the SLI as good events ÷ valid events. Then add the SLO.
- Choose the SLO with the product owner. Use past data, and do not promise more than your dependencies give you.
- Write an error budget policy before you need it. For example: if the budget for 4 weeks is spent, stop feature launches and work on reliability until the service is back within the SLO 6.
- Put a trace ID in every log line. Then you can jump from a slow trace to the logs of that exact request.
- Keep monitoring separate from what it watches. In 2021, Roblox was down for 73 hours, and its monitoring depended on Consul, the system that was failing. That slowed the team's diagnosis 8. Slack's dashboards and alerts also failed in its January 2021 outage, because they reached their databases through the overloaded network 9.
- Delete or fix every alert that pages without needing action. Alert noise trains people to ignore the real alert.
With AI
What to ask the agent
"Write a Prometheus recording rule for the checkout SLI: the share of requests that return a non-5xx status in under 500 ms. Then write burn-rate alerts for a 99.9% SLO, with 1 hour and 5 minute windows at 14.4, and 6 hour and 30 minute windows at 6."
"Add OpenTelemetry tracing to this HTTP handler. Add the trace ID to every log line it writes."
What to check yourself
- The SLI counts only valid requests. Decide on purpose whether health checks and 4xx errors from bad user input count.
- The burn-rate maths matches your SLO. A burn rate of 14.4 for a 99.9% SLO means an error rate of 1.44%.
- Each alert uses both a long and a short window.
- The latency SLI uses a percentile or a threshold count, never an average.
- Logs do not contain passwords, card numbers or other personal data.
Check yourself
Your progress is saved only in this browser. Export it to keep it safe.
You have finished 5 lessons. Your progress lives only in this browser. Export a copy so you don’t lose it.
Go deeper
Show 9 sources and related lessons
- OpenTelemetry documentation: Signals (opens in a new tab)
Short definitions of traces, metrics, logs and baggage in the most widely used open standard. - Google, Site Reliability Engineering, chapter 6: Monitoring Distributed Systems (opens in a new tab)
The four golden signals, and why averages hide slow requests. - Google, Site Reliability Engineering, chapter 4: Service Level Objectives (opens in a new tab)
What SLIs, SLOs and SLAs are, and why 100% is the wrong target. - Google, Site Reliability Engineering, chapter 3: Embracing Risk (opens in a new tab)
Where error budgets come from, and how they settle the fight between speed and safety. - Google, Site Reliability Engineering, Appendix A: Availability Table (opens in a new tab)
How much downtime each number of nines allows per year, quarter, month and day. - Google, The Site Reliability Workbook, chapter 2: Implementing SLOs (opens in a new tab)
How to choose SLIs, pick a time window, and write an error budget policy. - Google, The Site Reliability Workbook, chapter 5: Alerting on SLOs (opens in a new tab)
Burn rates and the multiwindow, multi-burn-rate alerts used in this lesson. - Roblox, “Roblox Return to Service 10/28–10/31, 2021” (opens in a new tab)
A 73-hour outage where monitoring depended on the system that was failing. - Slack Engineering, “Slack's Outage on January 4th 2021” (opens in a new tab)
Dashboards and alerts failed during the outage because they depended on the broken network.
Real incident: Roblox, 28 Oct 2021: Roblox outage: 73 hours down after Consul broke
Real incident: Slack, 4 Jan 2021: Slack outage: post-holiday traffic overloaded a cloud network link
Case studies: Stripe: Canonical log lines: one rich log line per request
Related: Alerting and on-call · Distributed tracing in practice · Incident response and postmortems
Next on this line: Alerting and on-call explains how to page humans only for what matters.