System Design · 05. Reliability · 8 min · Beginner
Observability
See inside a running system with logs, metrics and traces.
In short
Logs tell what happened, metrics tell that something changed and where, and traces show the path of one request. Dashboards and the four golden signals show health at a glance.
An SLO turns "fast enough" into a number, the error budget says how much failure is allowed, and alerts fire on user pain so the team finds problems before the users do.
Key ideas
- Observability means you can ask new questions about a running system and answer them from the data it already produces. (step 1)
- Latency, traffic and errors show what users feel. Saturation shows what is about to hurt them. (step 6)
Good to know
- Pass the trace id along in a header (W3C
traceparent), so every service adds its spans to the same trace. (step 4) - Keep one overview dashboard for the whole service and link each panel to a more detailed one. (step 5)
- 100% is the wrong target: it costs far too much and users cannot tell the difference after about 99.99%. (step 7)
Watch out
- Never log passwords, card numbers or tokens. Logs are copied around and kept for months. (step 2)
- Do not put unbounded values such as user_id in metric labels. Each value makes a new series, and a million of them break the store. (step 3)
- Too many alerts and people start to ignore them. If a page needs no action, delete it or turn it into a ticket. (step 8)
Key numbers
- Time to find cause
- 2 min
- Error budget left
- 98%
Terms
- Observability
- How well you can understand what a running system is doing from the data it produces.
- Structured log
- A log line written as fields (often JSON), including a request id, so it can be searched.
- Metric
- A number sampled over time, such as requests per second, cheap to store and graph.
- Trace and span
- A trace follows one request through the services; each timed step is a span.
- Percentile (p99)
- The value below which that share of requests falls; p99 is the time that 99 of 100 requests beat.
- Golden signals
- Latency, traffic, errors and saturation: the four things to watch for every service.
- SLI
- A measured number of how well the service is doing for users, such as the share of fast, successful requests.
- SLO
- The target for an SLI over a period, such as 99.9% over 30 days.
- Error budget
- The amount of failure the SLO allows; when it is spent, reliability work comes first.
- Burn-rate alert
- An alert that fires when the error budget is being used up too quickly.