Skip to content

Metrics and the four golden signals

A service can have hundreds of metrics. The Google SRE book’s chapter on monitoring says that if you can measure only four things about a user-facing system, they should be these.

  • Latency. The time it takes to serve a request. The SRE book stresses telling the latency of successful requests from the latency of failed ones. One reason is that an error can come back at once, and mixing fast errors in makes the service look quicker than it is.
  • Traffic. How much demand is placed on the service, in a high-level measure that suits it. For a web service that is requests per second.
  • Errors. The rate of requests that fail, whether explicitly (an HTTP 500), implicitly (a 200 with the wrong content) or by policy.
  • Saturation. How full the service is, with an emphasis on the resources that are most constrained.

None of the four is enough alone. Latency up with traffic up is probably load. Latency up with traffic flat is something that got slower. Errors up with saturation at its limit is a service turning requests away. The signals are read as a set, against what is normal for this service.

The lab is the shop from the previous lesson, with one thing wrong at a time. Each incident is the shop run by the simulation engine with one fault, and you see only what the monitoring shows. The lab opens on Incident 1. Before you read on, look at Services: the four golden signals, pick the component you think is the cause and press Check my answer. Then come back.

Something is wrong in the shop, and you can only see what the monitoring shows: dashboards for each service, a trace of one request, and the error budget. Find the component that is the cause.

Incident

Each incident is the shop run by the engine with one thing wrong. You see what the monitoring shows, not what is wrong.

What users feel

Traffic entering the shop
300 requests/snormal: 300 requests/s About normal
Time to answer
mean 71 ms · p95 184 ms · p99 267 msnormal: mean 41 ms · p95 126 ms · p99 197 ms About normal
Requests that fail
0.00215% of requestsnormal: 0.00215% About normal

The mean is exact. The p95 and the p99 are estimates from a gamma fit (see the model notes).

Error budget
The share of requests that must succeed over 30 days.
The budget
43.2 min of complete outageThe share of requests that must succeed over 30 days.
Burn rate
0.02×0.00215% of requests fail, against the 0.1% the SLO allows.
Budget gone in
It lasts the whole windowA burn rate of 1 spends the budget exactly over the 30 days.

This does not page: the burn rate is under 14.4×.

Only failed requests spend the budget. A request that is slow but succeeds does not, so a slowdown can hurt users and leave the budget untouched.

Alerts

A symptom alert watches what users feel, so it fires whatever the cause. A cause alert watches one component for one failure that someone expected: it names the component, but only when that failure is the one happening.

Symptom alerts firing: 1. Cause alerts firing: 0.

Alert rules, and whether they fire now
AlertKindFires whenNowStatus
Error budget burning fastSymptomthe burn rate is 14.4× or more0.02× Quiet
Whole request slowSymptomthe p95 is above 150 ms184 ms Firing
Shop application saturatedCauseit is at 80% of its capacity or more38% Quiet
Shop application failingCause1% of its calls or more fail0% Quiet
Product database saturatedCauseit is at 80% of its capacity or more60% Quiet
Product database failingCause1% of its calls or more fail0% Quiet
Payment provider saturatedCauseit is at 80% of its capacity or more2% Quiet
Payment provider failingCause1% of its calls or more fail0.0431% Quiet
Email delivery service saturatedCauseit is at 80% of its capacity or more2% Quiet
Email delivery service failingCause1% of its calls or more fail0% Quiet

Services: the four golden signals

Each card is one service’s dashboard, now against normal: the same system with no incident, at its usual traffic. ▲ and ▼ mark a figure well above or below normal.

Shop application
Latency
p95 60 msp50 14 ms · p99 92 ms · normal p95 60 ms About normal
Traffic
300 calls/snormal 300 About normal
Errors
0% of calls failnormal 0% About normal
Saturation
38% of capacityqueue 0 of 400 · normal 38% About normal

Time in the service itself, not counting the calls it makes.

Time to answer, counting the calls it makes: 71 ms (normal 41 ms)

Failures as its callers see them: 0.00215% (normal 0.00215%)

Product database
Latency
p95 120 msp50 28 ms · p99 184 ms · normal p95 30 ms Higher than normal
Traffic
300 calls/snormal 300 About normal
Errors
0% of calls failnormal 0% About normal
Saturation
60% of capacityqueue 0 of 125 · normal 15% Higher than normal

Time in the service itself, not counting the calls it makes.

Failures as its callers see them: 0% (normal 0%)

Payment provider
Latency
p95 300 msp50 69 ms · p99 461 ms · normal p95 300 ms About normal
Traffic
15 calls/snormal 15 About normal
Errors
0.0431% of calls failnormal 0.0431% About normal
Saturation
2% of capacityqueue 0 of 10000 · normal 2% About normal

Time in the service itself, not counting the calls it makes.

Failures as its callers see them: 0% (normal 0%)

Email delivery service
Latency
p95 180 msp50 42 ms · p99 276 ms · normal p95 180 ms About normal
Traffic
15 calls/snormal 15 About normal
Errors
0% of calls failnormal 0% About normal
Saturation
2% of capacityqueue 0 of 5000 · normal 2% About normal

Time in the service itself, not counting the calls it makes.

Failures as its callers see them: 0% (normal 0%)

Trace of a request

A trace follows one request through the services, with one span for each. Each span is the mean time the engine gives for that service; real spans vary from request to request.

A usual request: 61 ms in all (normal 31 ms)
ServiceCallsStarts atOn the wireIn the serviceShareTimeline
Shop application10 ms—20 ms33%
Product database120 ms1 ms40 ms67%

The spans add up: 20 ms in Shop application + 1 ms on the wire to Product database + 40 ms in Product database = 61 ms.

A checkout request: 256 ms in all (normal 226 ms) It also calls the services that only some requests call.
ServiceCallsStarts atOn the wireIn the serviceShareTimeline
Shop application10 ms—20 ms8%
Product database120 ms1 ms40 ms16%
Payment provider161 ms25 ms100 ms49%
Email delivery service1186 ms10 ms60 ms27%

The spans add up: 20 ms in Shop application + 1 ms on the wire to Product database + 40 ms in Product database + 25 ms on the wire to Payment provider + 100 ms in Payment provider + 10 ms on the wire to Email delivery service + 60 ms in Email delivery service = 256 ms.

A service called several times is drawn as one row, with its number of calls.

Weighted by how often each call is made, the spans average 71 ms over all requests. The engine’s mean is 71 ms: they agree.

Your diagnosis

Which component is the cause?

Illustrative values, not benchmarks of any real product.

Model notes

Assumptions

  • Requests arrive at random, as a Poisson process, at a constant average rate.
  • Each node is one queue, served first-come first-served by several identical slots (instances × concurrency).
  • Service times are random with the stated mean; by default they are exponentially distributed.
  • Each node is analysed separately, with the traffic it receives treated as Poisson.
  • The dashboards show a steady state at the traffic shown, not a time series. “Normal” is the same system with no incident, at its usual traffic.
  • The shop application calls the product database on every request, and the payment provider and the email service on 5% of them (checkout). The calls are made one after another.

Simplifications

  • Above capacity there is no steady state. The model switches to a fluid approximation: the node serves at capacity, its queue grows until it reaches its limit, and further requests are rejected.
  • Percentiles assume an exponential tail. A service-time variability other than exponential changes the mean wait but not the shape of the tail.
  • A node frees its slot as soon as it has done its own work, before waiting on the services it calls. Real thread-per-request servers hold the slot, so a slow dependency exhausts them faster than this model shows.
  • A request calls its dependencies one after another. Parallel fan-out is not modelled.
  • When a caller times out and gives up, the callee still finishes the work, so abandoned requests keep consuming capacity.
  • Retries add load. Their backoff and jitter decide when that load arrives, which only the per-request simulation shows.
  • Retry feedback is solved from the healthy starting point, so it finds one stable outcome. Systems that stay stuck in overload after the cause is gone are not shown.
  • A throughput limit (for example maximum writes per second) is modelled as slower service, not as a separate rate limiter.
  • A caller’s timeout counts the mean time its dependencies take, not their full distribution.
  • Latency percentiles for a whole request are estimated, over every request, including those that are rejected and fail quickly. The mean is exact, and the percentiles come from a gamma distribution that has that mean and the variance of the time spent in each component.
  • A trace shows averages, not one random request: each span is the mean time the engine gives for that service, a service does its own work first, then makes its calls. Real spans differ from request to request.
  • The error budget treats the error rate shown as if it lasted for the whole 30 days. It is a rate of spending, not a record of what has been spent.
  • Only whole-request errors count against the budget, so a slowdown that causes no errors does not move it. The whole-request median is not shown: a gamma fit is poor when a small share of requests is much slower than the rest.

Parameter values are illustrative. They are not benchmarks of any real product.

At the top, Time to answer for the whole request has a mean of 71 ms against 41 ms normally, and Requests that fail is at its normal 0.00215%. Users are slower, and nothing fails.

Now read the four cards. The Shop application, which users call, shows its own Latency at a p95 of 60 ms, the same as normal. Traffic is 300 calls/s, Errors is 0% and Saturation is 38%, all about normal. It is the card of a healthy service, and below it a line says its time to answer, counting the calls it makes, is 71 ms against 41 ms normally. The application is waiting for something.

The Product database card is different. Its Latency p95 is 120 ms against 30 ms normally, four times higher. Its Traffic is 300 calls/s, exactly normal, and its Errors are 0%. Its Saturation is 60% of capacity against 15% normally, also four times higher.

That combination is the signature of slow work. The database gets the same calls as always and each one takes four times as long, so it is busy four times as much: utilisation is arrival rate times time per call, divided by capacity, and the time per call went up fourfold. Saturation is higher than normal, but 60% is far from a limit, and no queue has formed. If the problem were too much work, traffic would be up.

Now choose Incident 4. At the top, Traffic entering the shop is 900 requests/s against 300 normally. The Shop application is the component in trouble: its Saturation is 113% of capacity with its queue at 400 of 400, and Errors show 11.1% of calls failing. The arithmetic is in the lab’s scenario: 2 instances, each serving 8 requests at once for 20 ms each, can serve 2 × 8 / 0.020, which is 800 requests a second. At 900 the demand is 900 / 800, which is 113% of capacity, and the 100 a second that do not fit are turned away: 100 out of 900 is 11.1%.

The Product database in the same incident has a Traffic of 800 calls/s against 300, and it looks alarming until you read the rest of its card: Latency p95 30 ms, as normal, and Saturation 40%. It receives the 800 requests a second that got through the Shop application, and handles them well. More traffic is not a fault unless the service cannot take it.

The p95 on each card is a position in a distribution, as the lesson on percentiles and tail latency explained. A metrics system has to get it from somewhere.

The Prometheus documentation compares two ways. A summary computes quantiles inside each instance, and the documentation says that aggregating precomputed quantiles from a summary rarely makes sense: averaging them gives statistically nonsensical values. A histogram counts how many observations fell in each range, and those counts can be added across instances, after which the quantile is estimated from the combined counts. So the latency of a fleet has to be a percentile of merged histograms, not an average of the instances’ percentiles.

A percentile read from a histogram is an estimate. The documentation shows that a classic histogram interpolates inside a bucket, so its error depends on where the bucket edges are compared with where the requests actually fall. Choose buckets around the values you care about, such as the SLO threshold of the next lessons.

What happens if you read only the dashboard of the service users call?

Section titled “What happens if you read only the dashboard of the service users call?”

In Incident 1 the Shop application is the service users call, and every one of its four signals is normal. A team that watches only that dashboard sees a healthy service and slower users. The slow part is one hop down, and it only shows up when the application’s own time is told apart from the time spent waiting for its calls. That is what the single line under the card does: it counts the time with the calls it makes. A dashboard that mixes the two, as a request timer around the whole handler does, reports the slowness at the wrong service. This is why each service’s dashboard measures the time in the service itself, and why the next lesson draws the hops of one request.

  • The four golden signals are latency, traffic, errors and saturation. Read them together, against the service’s own normal.
  • Slow work shows as latency up with traffic flat. In Incident 1 the Product database’s p95 is 120 ms against 30 ms, its traffic is 300 calls/s as normal, and its saturation is 60% against 15%.
  • Too much work shows as traffic up. In Incident 4 the shop gets 900 requests/s against 300, so the Shop application is at 113% of its 800 requests a second and turns away 11.1%.
  • A caller can look slow only because it waits for a callee. The Shop application’s own p95 is 60 ms in Incident 1 while its time to answer with its calls is 71 ms against 41 ms.
  • A percentile for a fleet comes from merged histograms. Averaging the percentiles of instances gives a meaningless number.

Next: traces and spans, which show where one request lost its time.

Your progress

Built by GhaziAlibi.

© ShardCraft. All rights reserved.