Service levels and alerting — study guide

The concept's fragments, read in order.

For your capstone Take your own app to production

Your app needs a definition of working before anything can alert on it, and that definition is two SLOs measured at the load balancer, availability and latency, each with an error budget and burn-rate alerts. A page that fires is where incident response starts.

Say a bad configuration value at 14:00 makes 10% of requests return 503, a burn rate of 100. By 14:10 the last hour's error ratio has passed 1.44%, the last five minutes agree, and the page fires. The dashboard shows CPU at a calm 40%, which is why CPU was never the alert. You fix the value at 14:20, and about five minutes later the short window drops under the threshold and the page clears, instead of ringing for the rest of the hour.

What working means, in numbers

"Is the app up?" sounds like a question with a yes-or-no answer, and it is not one. Your app can answer its health check while every login fails, or serve every page in four seconds when users gave up after one. Before you can say whether it is working, you have to decide what working means, and the only definition that holds up under pressure is a number measured from the user's side of the screen.

That decision has a small vocabulary. A service level indicator (SLI) is the measurement: the fraction of requests that succeeded, or that came back fast enough. A service level objective (SLO) is the target for that measurement over a stretch of time, such as 99.9% of requests succeeding over 30 days. The gap between the target and perfection is the error budget, the amount of failure you have agreed to tolerate, and the speed at which you are spending it is the burn rate.

Observability supplies the signals and the idea of an alert threshold; what it leaves open is where the line belongs, and the answer here is wherever users start to notice. Alerting hangs off those numbers rather than off whatever graph looks alarming today. A person gets paged when the budget is burning fast enough that users are being hurt and waiting would make it worse; slower trouble becomes a ticket, and everything else stays on a dashboard. The aim is a pager that rings rarely and is right when it does, so that the person holding it still believes it.

Service level indicators: measure what users feel

an indicator counts good events among valid ones every request seen at the load balancer out of scope not counted other hosts or paths in scope valid requests 10,000 good: 9,993 bad: 7 not a 5xx 5xx error good bad, drawn wider all 10,000 valid requests availability = good / valid = 9,993 / 10,000 = 99.93% a latency indicator has the same shape: good means answered within 300 ms
Requests seen at the load balancer are first scoped to the valid ones the indicator covers, valid requests are then sorted into good and bad, and the indicator is the count of good divided by the count of valid: 9,993 good out of 10,000 valid is 99.93 percent.

A service level indicator (SLI) is a number you could explain to a user. It is written as a ratio: good events divided by valid events, so it runs from 0%, where nothing works, to 100%, where nothing is broken. Valid events are the ones the indicator is meant to cover, scoped by things like hostname or request path; good events are the valid ones that went the way the user wanted. Writing every indicator as the same kind of fraction is what lets you set targets on them, compare them and alert on them with one piece of arithmetic.

For a request-driven app like yours, two indicators carry most of the weight. Availability is the proportion of requests that got a successful response, where the usual rule is that a 5xx status counts as a failure and every other status counts as success, including a 404 for a page that does not exist, because that was the right answer. Latency is the proportion of requests answered faster than a threshold, such as 300 ms. Google's SRE guidance suggests keeping to five or fewer indicator types, and for a small app these two are a sound start.

Where you count matters as much as what you count. The application's own logs miss every request that never reached it, and a crashed container cannot log its own absence. The load balancer in front of your app sees those requests too, which puts its numbers closer to what users experience; probes from outside, or measurements taken in the user's browser, get closer still at more engineering cost. The pragmatic advice is to start with what you can already measure, and that is usually the load balancer.

Latency carries one more trap: never average it. An average of about 50 ms can sit on top of 5% of requests running twenty times slower, and those are the users who leave. Counting the fraction of requests under a threshold, or reading a high percentile such as the 95th or the 99th, keeps that slow tail in view, and the tail is the part a person actually feels.

Service level objectives: a target over a window

An indicator says how things are; a service level objective (SLO) says how they should be. It is a target for one indicator over a window of time: 99.9% of valid requests succeed, measured over a rolling 30 days, or 95% of requests are answered within 300 ms over the same window. That second one is the familiar "p95 latency under 300 ms" rewritten as a fraction of requests, so it behaves like every other indicator. The window decides how long a bad afternoon is remembered; Google's SRE workbook calls a four-week rolling window a good general-purpose choice, and a rolling 30 days works the same way.

The tempting target is 100%, and it is the wrong one. No user can tell 100% from 99.999%, because their laptop, their home Wi-Fi and their internet provider fail far more often than that, so the last sliver of reliability is lost in noise nobody notices. Each extra step of reliability can also cost many times more than the one before it. Worst of all, a 100% target forbids change, and change is the most common way outages start: the only app that never breaks is one nobody ever deploys.

An SLO is also not an SLA. A service level agreement (SLA) is a contract with users that carries consequences, usually money back, when it is missed; if missing the target has no explicit consequence, it is an SLO. Teams that offer an SLA set their internal SLO tighter than the promise, so they have room to notice and fix chronic problems before the contract is breached. For your app the SLO is the one that matters: a promise you make to yourself about what your users will get.

The error budget: failure you are allowed

99.9% over 30 days: 0.1% of 43,200 minutes = 43.2 minutes to spend day 0 day 30 the window day 9: outage, 20 min day 21: bad release, 10 min day 0 43.2 min left outage spends 20 after day 9 spent 20 23.2 min left release spends 10 after day 21 spent 30 13.2 min left minutes assume steady traffic: a full outage at the 50 req/s peak spends it all in about 3.3 minutes
A 99.9 percent availability target over a 30-day window allows 43.2 minutes of failure; a 20-minute outage on day 9 and a 10-minute bad release on day 21 each spend part of that budget, leaving 13.2 minutes at the end of the window; the minutes assume steady traffic, since at the 50 requests per second peak a full outage spends the whole budget in about 3.3 minutes.

If the objective is 99.9%, the missing 0.1% is not a shortfall to apologize for; it is a budget. The error budget is one minus the SLO: the amount of unreliability you have agreed, in advance, to tolerate over the window. Writing it down turns "be reliable" into a quantity you can measure, spend and run out of.

Work it in time first. A 30-day window holds 30 × 24 × 60 = 43,200 minutes, and 0.1% of 43,200 is 43.2, so a 99.9% availability target allows 43.2 minutes of total outage per 30 days. That holds only if traffic is steady, because the target counts requests, not minutes, and a minute of outage costs as many failed requests as arrived in it. The same sum covers the other common targets: 99% allows 432 minutes, or 7.2 hours; 99.5% allows 216 minutes, or 3.6 hours; 99.95% allows 21.6 minutes; and 99.99% allows 4.32 minutes, barely long enough to read a page and open a laptop. Every extra nine divides the budget by ten. A 20-minute outage on day 9 and a bad release that takes the app down for 10 minutes on day 21 together spend 30 of the 43.2 minutes at steady traffic, leaving 13.2 for the rest of the window.

Counting requests is the more honest version for an availability indicator, because a partial failure spends only part of the budget. At 99.9%, every 1,000,000 requests in the window may include 1,000 failures. An hour in which 1% of requests fail spends one hundredth of what an hour of total outage would, and a request count captures that where a count of bad minutes would not. Your app serves about 10 million requests a month, so its budget is 10,000 failed requests. Traffic is not steady, though: at the peak of about 50 requests per second, a full outage fails 50 × 60 = 3,000 requests a minute and spends the whole month's budget in 10,000 / 3,000 = about 3.3 minutes, so the 20-minute outage above, had it hit at peak, would have failed 60,000 requests, six months' worth. The same outage in a quiet hour costs far less.

The budget is meant to be spent like a monthly allowance - it exists to be spent on things you choose, and once it is gone the optional spending stops until it refills. Releases, experiments and risky migrations all draw on it, because change is the most common way outages begin. The other half is an error budget policy agreed before anyone needs it. Google's example policy says that once the budget for the window is gone, all changes and releases stop except the most urgent fixes and security fixes until the service is back within its SLO. With that written down, "should we ship today?" stops being an argument and becomes a lookup.

Burn rate: how fast the budget is going

slope, not level, decides how urgent a burn is error budget spent 0% 50% 100% day 0 10 20 30 days into the 30-day window burn rate 1 6 14.4 burn rate 14.4: budget gone in about 2 days burn rate 6: budget gone in 5 days burn rate 1: budget gone exactly at day 30 zoom: budget spent in the first hour 2%: page 0.83% 0.14% 0 1 h
Error budget spent plotted against the 30-day window: at burn rate 1 the budget runs out exactly at day 30, at burn rate 6 it runs out in 5 days, and at burn rate 14.4 it runs out in about 2 days after spending 2 percent in the first hour, so the steepness of the line, not how much is left, decides how urgent the burn is.

How much budget is left tells you less than how fast it is going like a fuel gauge on a long drive, where how fast the needle is falling, not where it sits, tells you whether you will make it. Burn rate is that speed: the error rate you are seeing divided by the error rate the SLO allows. At 99.9% the allowed error rate is 0.1%, so 0.1% of requests failing is a burn rate of 1, which spends the budget exactly by the end of the window. 1% failing is a burn rate of 10 and, if traffic were steady, would empty a 30-day budget in 3 days. Every request failing is a burn rate of 1,000 and empties it in about 43 minutes, which is the 43.2-minute budget seen from the other side; real traffic is not steady, and at the busy-hour peak a total outage empties it in about 3.3 minutes.

Turning a burn rate into an alert is one multiplication. A 30-day window is 720 hours. A burn rate of 14.4 held for one hour spends 14.4 / 720 = 2% of the budget; at 99.9% that is 1.44% of requests failing, and if it kept up it would empty the whole budget in 720 / 14.4 = 50 hours, about two days. A burn rate of 6 held for six hours spends 36 / 720 = 5%, and a burn rate of 1 held for three days spends 72 / 720 = 10%. Google's SRE workbook recommends exactly these three as starting points for a 99.9% objective: the first two page someone, the third opens a ticket.

Each of those alerts checks two windows, not one. The long window (one hour, six hours, three days) proves the burn is big enough to matter; a short window one twelfth as long (five minutes, thirty minutes, six hours) proves it is still happening, and the alert fires only when both are over the threshold. Without the short window, a one-hour average keeps an alert firing for up to an hour after the errors stop. With it, the page clears about five minutes after recovery, so the person holding the pager is not left chasing a problem that has already ended.

Alert on symptoms, not causes

Every alert answers one of two questions: what is broken, or why. The first is a symptom, something a user would notice: errors coming back, responses arriving slowly, the error budget burning. The second is a cause: the database refusing connections, a CPU pinned near 100%, a disk filling up. Google's SRE book draws the line sharply and puts paging on the symptom side, keeping cause-based signals as aids to debugging once someone is already looking.

Causes make poor alarms in both directions. A CPU can sit at 95% while every request is still answered in time, and a page for it wakes someone to look at a graph and go back to sleep. Meanwhile users can be suffering from a cause nobody thought to put a threshold on, such as a bad configuration value or an expired certificate, and only a symptom alert notices that. An alert on the error ratio catches every cause that reaches users, including the ones you have not imagined yet.

Symptoms are also relative to where you stand. Slow database reads are a symptom to whoever runs the database and a cause to whoever runs the website in front of it. For your app you are both, so the symptoms worth paging on are measured at the edge, where requests arrive from users.

Causes still have homes: the dashboards you open during an investigation, and the metrics that help explain a symptom once it fires. The narrow exception is a cause that is both definite and imminent, such as a part that is nearly full or a service left with no spare redundancy; the same SRE guidance counts those as close enough to user-visible to act on. Everything else about causes is for diagnosis, not for waking people up.

Page or ticket

where an alert condition should go users are being hurt, and a person must act now? page burn rate 14.4 over 1 h, or 6 over 6 h yes: wake someone no a person must act, but within a few days? ticket burn rate 1 over 3 days handled the next working day yes: queue it no dashboard or log only wakes nobody belongs here: high CPU while requests stay fast, one container restart that users never saw
An alert condition is routed by two questions: if users are being hurt and a person must act now, it pages someone; if a person must act within a few days, it opens a ticket; otherwise it stays on a dashboard or in the logs and wakes nobody.

Google's SRE guidance says there are only two valid ways to get a person to act: a page, which interrupts them now, and a ticket, which waits in a queue. Everything else is logging, and nobody reads logs unless something else sent them there. Every alert condition therefore has three possible destinations, and choosing among them is most of alert design.

A page has to earn the interruption. The test the SRE book proposes is that it signals something urgent, actionable, and actively or imminently visible to users, and that responding to it takes thought; if the response is a fixed routine, it should be automation, not a page. A ticket is for problems where a person must act but nothing is lost if they act within a few days, such as a slow burn that would spend 10% of the budget over three days, picked up the next working day. Everything else, from CPU curves to a single container restart nobody noticed, belongs on a dashboard.

The cost of routing too much to the pager is alert fatigue. A person can respond with real urgency only a few times a day; past that, they skim, second-guess or ignore pages, and sooner or later a real one is lost in the noise like a smoke alarm that goes off every time someone makes toast, until someone pulls the battery and it stays silent on the night of a real fire. More pages do not make a system safer; they make the pager less believed.

The SRE workbook names four measures that keep an alert honest. Precision is the share of alerts that were about something significant; recall is the share of significant events that raised an alert; detection time is how long an alert takes to fire; reset time is how long it keeps firing after the problem is gone. The workbook rates multiwindow burn-rate alerts well on precision, recall and reset time, at the price of more parameters to manage. What the person does once the page arrives is the subject of incident response, which builds on this.

Your app's first service levels

For your app, all of this fits on one page. Start with two SLOs, both measured at the load balancer over a rolling 30 days: 99.9% of valid requests return something other than a 5xx, and 95% of them are answered within 300 ms. That gives an availability budget of 1,000 failed requests for every million served, which at about 10 million requests a month is 10,000. At steady traffic that would be 43.2 minutes of total outage, but a full outage at the 50 requests per second peak fails 3,000 requests a minute and spends the month's budget in about 3.3 minutes. The latency budget is 5% of requests allowed to take longer than 300 ms.

Then three alerts for each SLO, and no more. Page when the error ratio is above 14.4 times the allowed rate over both the last hour and the last five minutes, or above 6 times over both the last six hours and the last thirty minutes; open a ticket when it is above the allowed rate over both the last three days and the last six hours. At 99.9% those thresholds are 1.44%, 0.6% and 0.1% of requests failing. The same three burn-rate alerts apply to the latency SLO, whose budget is the 5% of requests allowed to be slow. CPU, memory, database connections and container restarts go on the dashboard, where they explain a page instead of causing one.

Expect to tune. Busy hours may reach 50 requests per second, but with a few thousand daily users the small hours can be thin, and percentages behave badly on thin traffic. At 10 requests in an hour, a single failed request is 10% of that hour's traffic, a burn rate of 100, enough to trip the one-hour page on its own, although against a month of about 10 million requests it spends one ten-thousandth of the budget. Check whether each page was real, adjust windows and thresholds when one was not, and revisit the targets as the user base grows. The aim stays the same throughout: a definition of working your users would agree with, and a pager that rings only when it stops being true.

Next on your path to Take your own app to production: