Skip to content

Observability

Observability is how well you can understand what a running system is doing, and why, from the data it emits, without shipping new code to ask a new question. Monitoring checks the failures you predicted. Observability helps with the ones you did not. In a design you need both: a few signals that tell you users are hurting, and enough context to find the cause quickly across dozens of services.

SignalWhat it isAnswersCost driver
MetricsNumbers aggregated over time, with labelsIs it broken? How much? Since when?Number of time series (cardinality)
LogsTimestamped records of discrete eventsWhat exactly happened to this request?Volume (GB ingested and kept)
TracesThe tree of spans for one request across servicesWhere did the time go? Which hop failed?Spans per request × sampling rate

A typical investigation moves through them in order. An alert fires on the checkout error-rate metric. You open an exemplar trace from the bad minute and see that the payments span takes 3 s and times out. Its logs, found by trace ID, show connection pool exhausted right after a deploy. Profiles, the emerging fourth signal, then show which function burns the CPU.

What to measure: RED, USE and the golden signals

Section titled “What to measure: RED, USE and the golden signals”
  • RED, for request-driven services: Rate (requests per second), Errors (failed requests per second), Duration (a latency distribution). Tom Wilkie proposed it for microservices. Dashboards that look the same for every service make on-call work much easier.
  • USE, for resources (CPU, memory, disks, NICs, but also thread pools, connection pools and queues): Utilisation, Saturation (work waiting: run-queue length, queue depth) and Errors. It comes from Brendan Gregg’s performance analysis method.
  • Four golden signals from Google’s SRE book: latency, traffic, errors and saturation. RED is the first three, and saturation brings in USE.

Two details matter. Measure latency of successes and failures separately, because fast errors make latency look great. Count errors you return deliberately (a 200 with an error body, an empty search result caused by a timeout) as errors too.

Latency is skewed, so averages hide the slow requests users notice. Use percentiles: p50, p95, p99, p99.9. They come from histograms, which count observations into latency buckets.

Percentiles do not average. Server A handles 9,000 requests, all at 40 ms. Server B handles 1,000, and 200 of them take 2 s. A’s p99 is 40 ms and B’s is 2,000 ms. Their average, 1,020 ms, describes nothing. The fleet’s true p99 is 2,000 ms, because the slow 2% of all requests sit on B. With other traffic mixes the average overstates the truth instead. The only correct method is to add the bucket counts first, then compute the percentile.

  • Prometheus summaries compute quantiles inside the process, so they cannot be combined across instances. Prefer histograms.
  • Classic histograms with fixed buckets are only as precise as the bucket containing the percentile. Choose boundaries around your SLO threshold, roughly exponential (Google’s SRE book suggests about ×3 apart).
  • Exponential or native histograms (OpenTelemetry exponential histograms, Prometheus native histograms) adjust bucket boundaries automatically, with bounded relative error and lower storage cost. Native histograms have been a stable Prometheus feature since 3.8 (scraping them is still opt-in), and Prometheus recommends them where your client libraries support them.
  • Exemplars attach a trace ID to a bucket sample, so you can jump from “p99 spiked” to a real slow trace.
  • SLI (service level indicator): good events ÷ valid events, measured as close to the user as practical. Example: the share of checkout requests that return non-5xx within 300 ms.
  • SLO (objective): the target for an SLI over a window, for example 99.9% over 30 days.
  • Error budget: 1 − SLO. For 99.9% over 30 days, that is 0.1% of requests, or 43.2 minutes of full downtime. When the budget is spent, reliability work takes priority over features. See availability patterns for what each extra nine costs.

Alert on the burn rate: how fast you are spending the budget, relative to spending it evenly over the window. A burn rate of 1 uses the whole budget in exactly 30 days. A burn rate of 14.4 uses it in about 2 days. Google’s SRE workbook recommends multiwindow, multi-burn-rate alerts for a 99.9% SLO:

SeverityLong windowShort windowBurn rateBudget used when it fires
Page1 hour5 minutes14.42%
Page6 hours30 minutes65%
Ticket3 days6 hours110%

The long window makes the alert significant, so a two-minute blip does not page anyone. The short window must also exceed the threshold, so the alert stops soon after the problem does. These alerts fire on what users experience, whatever the cause, which is why they replace dozens of “CPU above 80%” alerts. Keep resource alerts as dashboards or tickets.

A trace follows one request across services. It is a tree of spans, one per unit of work (an HTTP handler, a database query, a queue publish), each with a start time, a duration, a parent span and attributes.

sequenceDiagram
  participant GW as API gateway
  participant O as Orders
  participant DB as Orders DB
  participant P as Payments
  GW->>O: POST /orders<br/>traceparent:<br/>trace 4bf9, span a1
  O->>DB: INSERT order<br/>(span b2,<br/>parent a1)
  DB-->>O: ok, 4 ms
  O->>P: charge<br/>traceparent:<br/>trace 4bf9, span c3
  P-->>O: timeout after 3,000 ms
  O-->>GW: 504<br/>(whole trace<br/>3,020 ms)
  • Origins. Google’s Dapper paper (2010) set the template: propagate trace and span IDs through every RPC, sample to keep overhead low, and make instrumentation transparent by building it into shared libraries. Zipkin and Jaeger followed. OpenTracing and OpenCensus merged in 2019 to form OpenTelemetry.
  • Propagation. Context crosses process boundaries in headers. The W3C Trace Context traceparent header (a W3C Recommendation) carries a version, a 16-byte trace ID, an 8-byte parent span ID and flags. For async hops, put it in message headers so a trace continues through queues and Kafka topics.
  • OpenTelemetry (OTel) is the vendor-neutral standard: APIs, SDKs, the OTLP wire protocol and the Collector, which receives, processes and exports telemetry to any backend. It became a CNCF graduated project in May 2026. As of October 2026, the specification lists traces as stable across API, SDK and protocol, metrics with a stable API and protocol (SDK maturity varies by language), logs stable through a bridge API that connects existing logging libraries, and profiles in public alpha (announced March 2026) and not yet recommended for critical production use. Per-language maturity still varies, so check the SDK you use.
  • Sampling. Tracing everything at high volume is expensive. Head sampling decides at the start (keep 1%) and is cheap but blind to outcome. Tail sampling decides after the trace completes, keeping all errors and slow traces plus a small share of the rest. It needs all spans of a trace to reach the same collector instance, which usually means a load-balancing tier keyed by trace ID.

Write logs as structured events (JSON or logfmt) with stable field names, not free-form text:

{"ts":"2026-10-08T10:15:02.731Z","level":"error","service":"orders",
"msg":"payment call failed","trace_id":"4bf92f3577b34da6a3ce929d0e0e4736",
"span_id":"00f067aa0ba902b7","order_id":"o-81723","error":"deadline_exceeded",
"duration_ms":3000,"version":"2026.10.07-3"}
  • Include the trace ID in every log line. OTel log bridges and most logging libraries add it automatically, which is what links logs to traces. Older systems use a separate correlation or request ID header, and the idea is the same.
  • Prefer one wide event per request per service (all the useful context in one record) over dozens of narrow lines. Wide events can be queried like a table: which build, region and customer tier have the errors?
  • Log levels and sampling keep volume sane. Keep all errors, sample routine successes.
  • Never log secrets or personal data you do not need. Logs are often copied and kept for longer than the database is.

A metric’s cardinality is the number of distinct label combinations, and each one is a separate time series. They multiply:

LabelsDistinct valuesSeries
endpoint × method × status class50 × 4 × 51,000
× pod× 200200,000
× 14 series per histogram (12 buckets, sum, count)× 142.8 million
× customer_id× 10,00028 billion: unaffordable

Rules of thumb:

  • Bounded labels only in metrics: region, endpoint template (/users/{id}, never the raw path), status class, build version. Unbounded values (user ID, order ID, full URL, error message) go into traces and logs, which are built for high cardinality.
  • Aggregate early. Drop the pod label for dashboards that only need service-level views. The OTel Collector and recording rules can do this before storage.
  • Tier retention. Keep raw data for days, downsampled data for months. Move logs to object storage and query them on demand.
  • Sample traces with a tail-sampling policy rather than storing everything.
  • Budget telemetry like any resource. Tie each team’s bill to its usage. Observability spend that grows faster than traffic usually means a label or a log line exploded.
ChoiceBenefitCost
Metrics-firstCheap, fast, ideal for alertingNo per-request detail
Wide events and tracesAnswers new questions after the factStorage and query cost; sampling decisions
Head samplingSimple, low overheadMisses rare errors
Tail samplingKeeps the interesting tracesCollector state, routing by trace ID
Vendor agentQuick start, rich UILock-in; harder to switch backends
OpenTelemetry + CollectorPortable, one pipeline for all signalsYou run the pipeline; per-language maturity varies

Based on The System Design Primer by Donne Martin (CC BY 4.0). Restructured, rewritten and updated; site content is licensed under CC BY 4.0.