Observability
Monitoring asks “is the system up?”. Observability asks “can I answer a question I did not anticipate?”. You cannot predict every failure, so the goal is to leave enough evidence behind to explain one.
The 60-second answer
Section titled “The 60-second answer”Three signals: logs (discrete events, with structure), metrics (aggregatable numbers over time), and traces (causality across services via a shared trace id). Correlate them with a request id propagated through every call. Define SLIs as ratios of good events to total events, set SLOs from user expectations, and alert on burn rate against the error budget rather than on raw CPU. Instrument with OpenTelemetry so the backend (Prometheus, Grafana, Tempo, Jaeger) is a choice, not a rewrite.
The three pillars
Section titled “The three pillars”| Signal | Answers | Cost profile | Example |
|---|---|---|---|
| Log | What happened in this one case? | High per event; expensive at volume | {"level":"error","user_id":42,"msg":"payment declined","code":"insufficient_funds"} |
| Metric | How is the system behaving in aggregate? | Cheap, bounded by cardinality | http_request_duration_seconds{route="/orders",status="500"} |
| Trace | Where did this request spend its time? | Sampled; storage grows with span count | span db.query inside request 9f2c... |
Use each for what it is good at. Logs for detail, metrics for aggregation and alerting, traces for causality.
Structured, one JSON object per line, to stdout, with the platform collecting it.
{"ts":"2026-03-01T10:00:00.123Z","level":"error","service":"orders", "trace_id":"4bf92f3577b34da6","span_id":"00f067aa0ba902b7", "user_id":42,"route":"POST /orders","status":500, "msg":"downstream timeout","duration_ms":1002}Rules that make logs usable:
- Never log secrets, tokens, passwords, full card numbers or personal data. Redact at the logger, not at each call site.
- Include the trace id so a log line can be joined to a trace.
- Use levels consistently.
errormeans a human should look; if everything iserror, nothing is. - Log the decision, not just the outcome. “Rejected: rate limit exceeded, key=user:42” is debuggable; “rejected” is not.
- Sample or aggregate high-volume debug logs. Log volume is the most common observability bill.
Metrics
Section titled “Metrics”Four metric types in the Prometheus model:
- Counter: monotonically increasing (
requests_total). Query withrate(). - Gauge: current value (
queue_depth,connections_open). - Histogram: buckets, so you can compute percentiles server-side.
- Summary: client-side quantiles, cannot be aggregated across instances. Prefer histograms.
Cardinality is the trap. Every distinct label combination is a separate time series. Putting
user_id or a raw URL path in a label creates millions of series and kills the metrics backend.
Use route templates (/orders/:id), status classes, and a bounded set of labels.
# request rate by routesum by (route) (rate(http_requests_total[5m]))
# error ratiosum(rate(http_requests_total{status=~"5.."}[5m])) / sum(rate(http_requests_total[5m]))
# p99 latency from a histogramhistogram_quantile(0.99, sum by (le, route) (rate(http_request_duration_seconds_bucket[5m])))Two framework shortcuts worth knowing:
- RED for services: Rate, Errors, Duration.
- USE for resources: Utilisation, Saturation, Errors.
Traces
Section titled “Traces”A trace is a tree of spans sharing a trace_id. Each span has a span_id, a parent, a start time,
a duration and attributes.
POST /checkout 1,204 ms├── auth.verify 12 ms├── inventory.reserve 180 ms│ └── db.query SELECT stock 170 ms ← the problem├── payment.charge 900 ms│ ├── http.client POST /charges 880 ms│ └── retry (1) 20 ms└── db.query INSERT orders 40 msContext propagation is the hard part: the trace id must cross HTTP headers, queue messages,
and background jobs. W3C traceparent is the standard header. If a hop drops it, the trace ends
and you lose the causal chain precisely where it matters.
Sampling is necessary at volume:
- Head-based: decide at the start, e.g. 1% of requests. Cheap, but you may sample away the errors.
- Tail-based: buffer the whole trace and keep it if it is slow or errored. More useful, more infrastructure.
- Always keep 100% of traces for errors and for a sample of slow requests.
OpenTelemetry is the vendor-neutral SDK and protocol (OTLP) for logs, metrics and traces. The practical advantage: instrumentation stays, the backend can change. A collector sits between the app and the backend and handles batching, sampling and routing.
SLI, SLO, SLA
Section titled “SLI, SLO, SLA”| Term | Meaning | Example |
|---|---|---|
| SLI | The measured indicator | Proportion of requests served < 300 ms |
| SLO | The internal target for the SLI | 99.9% over 30 days |
| SLA | The contractual promise, with consequences | 99.5%, or service credits |
Good SLIs are ratios of good events to valid events, measured as close to the user as possible:
availability SLI = successful requests / valid requestslatency SLI = requests faster than 300 ms / valid requestsquality SLI = responses with complete data / responsesMeasure at the edge, not deep inside the service, or you will miss failures that never reach your handler.
Error budgets
Section titled “Error budgets”An SLO of 99.9% over 30 days allows about 43 minutes of full unavailability. That is the error budget.
- Budget remaining → ship features, take risks, run experiments.
- Budget exhausted → freeze risky changes and spend the time on reliability.
This converts “should we slow down?” from an argument into arithmetic, which is why it is popular.
Alerting
Section titled “Alerting”Alert on symptoms, not causes. A full disk is a cause; users getting errors is a symptom. Page on symptoms, ticket on causes.
| Alert | Type | Why |
|---|---|---|
| Error rate > 5% of requests for 5 min | Page | Users are failing now |
| p99 latency above SLO for 10 min | Page | Users are suffering now |
| Error budget burn rate > 14× over 1h | Page | Will exhaust the month’s budget in days |
| Disk > 80% | Ticket | Predictable, no need to wake anyone |
| Single instance down | Ticket | Capacity absorbs it |
Burn rate is the multiplier over the sustainable error rate. A 14.4× burn over one hour consumes 2% of a 30-day budget — that is the multi-window approach: a fast burn pages, a slow burn files a ticket. Multi-window alerts reduce both noise and missed incidents.
Every page must be actionable and have a runbook. Alert fatigue is a reliability risk: a team that ignores pages will ignore the real one.
The practical minimum
Section titled “The practical minimum”For a service you own, before launch:
- Request rate, error rate and latency per route (RED).
- Saturation: CPU, memory, connection pool, queue depth.
- A structured log with a request id, shipped off the box.
- Distributed tracing with context propagation, even at 1% sampling.
- A dashboard that answers “is it healthy right now?” in one screen.
- Alerts on the SLO, with a runbook.
- A synthetic check from outside your network — it catches DNS, TLS and load balancer failures that internal metrics never see.
Follow-up questions
Section titled “Follow-up questions”- Why does a high-cardinality label break a metrics system?
- What is the difference between head-based and tail-based sampling, and when do you need the latter?
- How do you trace a request that goes through a queue and a background worker?
- Your SLO is 99.9%. How many minutes of downtime is that per month?
- How would you alert on a slow dependency without paging for every blip?
- What does an error budget change about how a team ships?
Common traps
Section titled “Common traps”- “We have logs, so we are observable.” Unstructured logs without a request id are nearly useless under pressure.
- “Alert on CPU > 80%.” CPU is a cause. High CPU with healthy latency is not an incident.
- “Averages are fine.” Averages hide the tail, and the tail is what users feel.
- “Add a label for user id so we can filter.” That is how you take down the metrics backend.
- “Tracing is too expensive.” Sampling makes it cheap; the cost of not having a trace during an incident is higher.
- “SLOs are for big companies.” An SLO is a sentence and a number. Anyone can have one.