Incident Walkthrough: One Slow Checkout, Six Signals
Everything in the parts from What observability is to Cost and vendors is a component. This part runs them together on one realistic incident, so you can see which signal answers which question and where each join key comes from. The service names and numbers are illustrative; the mechanics are the ones described in the linked parts.
| Service | checkout-api → inventory-svc → PostgreSQL |
|---|---|
| Latency SLO | 99% of checkouts < 300 ms, over 30 days |
| Stack | OTel SDKs → Alloy/Collector → Mimir, Loki, Tempo, Pyroscope → Grafana |
| Change in flight | Canary v2.41 on 10% of pods |
Hop 1 — The alert: a metric decides something is wrong
At 14:02 the page fires. It is not "p99 > 300 ms"; it is the multi-window burn-rate rule from the Alerting and SLOs part. The SLI is a ratio of two counters taken from the latency histogram: requests under 300 ms (the le="0.3" bucket) over all requests. Both the 1-hour and the 5-minute windows are burning budget at more than 14.4×, which means "at this rate the whole month's budget is gone in about two days."
- alert: CheckoutLatencyBudgetBurn
expr: |
(
1 - sum(rate(http_server_request_duration_seconds_bucket{service="checkout-api", le="0.3"}[1h]))
/ sum(rate(http_server_request_duration_seconds_count{service="checkout-api"}[1h]))
) / (1 - 0.99) > 14.4
and
(
1 - sum(rate(http_server_request_duration_seconds_bucket{service="checkout-api", le="0.3"}[5m]))
/ sum(rate(http_server_request_duration_seconds_count{service="checkout-api"}[5m]))
) / (1 - 0.99) > 14.4
labels: { severity: page, service: checkout-api, slo: checkout-latency }Alertmanager routes on severity and service, groups for group_wait, and sends one page (see Alerting and SLOs). An inhibition rule mutes the lower-severity InventoryHighLatency warning that fired at the same time, so the on-call gets one notification, not four. Note what the alert does not know: which requests, which pods, or why. It was computed from two numbers per time bucket (see Metrics).
Hop 2 — The dashboard: slice the metric until one label explains it
The RED dashboard (see RED, USE and SLOs) shows that rate is normal and errors are flat, but the duration p99 has gone from 180 ms to 1.4 s. The first useful question is "is it everyone, or a subset?", and the only way to ask it is to re-aggregate the histogram buckets by a label that already exists:
histogram_quantile(0.99,
sum by (le, service_version) (
rate(http_server_request_duration_seconds_bucket{service="checkout-api"}[$__rate_interval])
)
)Two series come back: v2.40 flat at 180 ms, and v2.41 at 1.4 s. A deploy annotation on the panel lines up with the start of the burn. This works only because service.version was set as a resource attribute (see OpenTelemetry) and survived into Prometheus as a label. The le stays inside sum by, and you aggregate the buckets before you take the quantile, never after (see PromQL). If the team had dropped that label to save series (see Cost and vendors), this hop would turn into an hour of guessing.
Hop 3 — The exemplar: from an aggregate to one real request
The latency heatmap (a histogram panel, see Grafana) shows a band of observations in the 1–2.5 s buckets. Each bucket sample can carry an exemplar: the trace_id of one request that was counted in that bucket, attached by the SDK when the histogram was recorded (see Beyond the three pillars). Clicking the dot opens that trace in Tempo. This is the hop from "how many" to "this one". Without exemplars you would search Tempo with TraceQL instead, for example { resource.service.name = "checkout-api" && duration > 1s }. That still works, but only if a slow trace survived sampling. A head sampler at 1% keeps about 1 in 100 of these (see Traces).
Hop 4 — The trace: which hop, in what order
The waterfall shows a 1.38 s POST /checkout. 1.15 s of it is inside inventory-svc, and inside that span are 41 sequential child spans, each a SELECT against reservations lasting about 27 ms (db.system.name=postgresql, db.operation.name=SELECT, see OpenTelemetry). 41 × 27 ms ≈ 1.1 s. That is the N+1 shape: one query per cart item instead of one batched query. No metric could have shown this. The DB latency histogram is healthy, because each query is fast; the problem is the count and the order, which only the causal tree keeps (see Traces; reading a trace in depth is in the Distributed Tracing guide).
Hop 5 — The logs: why the code took that path
The trace says what happened; it does not say why inventory-svc stopped batching. In Grafana, a derived-field link from the span (see Grafana) runs a Loki query keyed on the same trace_id:
{service_name="inventory-svc"} | json | trace_id="4bf92f3577b34da6a3ce929d0e0e4736"Loki selects the stream by its labels, then greps the compressed chunks for the ID (see Log pipelines and storage). One structured line explains everything: {"level":"WARN","msg":"sku cache bypassed, falling back to DB","flag":"batch_reads","value":false,"trace_id":"4bf9…"}. A feature flag in v2.41 defaulted batch_reads to false. Note that trace_id is a field in the line (or structured metadata), not a Loki label: as a label it would create one stream per request and destroy the index (see Log pipelines and storage).
Hop 6 — The profile: confirm what the CPU was (not) doing
For completeness, the on-call opens the CPU profile for one v2.41 pod of inventory-svc over the incident window in Pyroscope (see Beyond the three pillars). The flame graph looks the same as before the deploy, and CPU utilization is flat. That is itself the finding: a CPU profile samples on-CPU stacks, so time spent waiting on the network for 41 round trips does not appear in it. It rules out the other hypothesis, "the new version burns CPU in serialization", and confirms the trace's story. The join key here is weaker than a trace_id: service.name + pod + time window. OTel profiles are still Alpha, and there is no standard span-to-profile link yet (see Beyond the three pillars, OpenTelemetry).
Resolution and what the signals cost
- 14:09 — rollback. The p99 for the remaining
v2.40pods is 180 ms. The 5-minute burn window drops below 14.4× within minutes. The 1-hour window lags, but the rule ANDs both windows, so the alert resolves quickly. That is exactly why the short window exists (see Alerting and SLOs). - Budget accounting. About 10% of traffic (the canary) was slow for about 7 minutes. That consumed a measurable slice of the month's 1% budget. The error-budget policy (see RED, USE and SLOs) decides whether the next release slips.
- The fix. Flip the flag default, add a test asserting a single query per cart, and add a span-count alert derived from traces (spanmetrics, see OTel Collector) or a
db_queries_per_requesthistogram, so the shape regression is caught by a metric next time.
| Hop | Question answered | Signal / tool | Join key that made the hop possible | What would have broken it |
|---|---|---|---|---|
| 1 | Is the user experience bad, by how much? | Metric · Prometheus/Mimir + Alertmanager | service, slo labels on the alert | Alerting on CPU instead of the SLI; averaging p99s |
| 2 | Who is affected? | Metric · Grafana + PromQL | service_version label | Dropping the label to save series; summaries instead of histograms |
| 3 | Show me one bad request | Exemplar | trace_id on the bucket sample | Exemplars disabled; slow trace not sampled |
| 4 | Which hop, in what order? | Trace · Tempo | traceparent propagated through every service | A proxy that strips headers; an uninstrumented hop |
| 5 | Why did the code do that? | Log · Loki | trace_id field in every log line | Unstructured logs; logger not wired to the OTel context |
| 6 | Was it compute or waiting? | Profile · Pyroscope | service.name + pod + time window | Profiling not enabled; inconsistent resource attributes |
The Invariants
- Guarantees: When every signal carries the same resource attributes and the logs and exemplars carry
trace_id, each step from alert to cause is a lookup by key, not a search. Metrics computed from 100% of traffic make the alert and the "who is affected" slice trustworthy even when traces are sampled. - Does not guarantee: That the one request you need was kept: exemplars and traces are samples, so a rare failure can still leave no trace behind. A CPU profile cannot show off-CPU waiting, and a span-to-profile link is not yet standardized. No signal tells you why unless someone wrote it down: the decisive log line in hop 5 existed because a developer logged the flag value.