Lesson 8 of 9 · 23m
Correlation: Logs, Traces, Metrics, and the Missing Context
Why a log line without identifiers is trivia, how trace correlation actually works, and which fields make cross-system investigation possible.
The worst log line in production is emotionally expressive and operationally empty: something went wrong. No actor, no request, no dependency, no version, no trace. It tells you pain occurred and gives you no path to the cause.
Correlation starts before the log is written
Every event should carry the identifiers available at emission time:
{
"ts": "2026-11-29T22:12:44.190Z",
"level": "error",
"service": "checkout",
"version": "2026.11.29-4",
"environment": "prod",
"trace_id": "7f3a2c91a1d64a10",
"span_id": "b91e0f42",
"request_id": "req_01JZQK",
"msg": "payment capture failed",
"error.kind": "stripe.CardError",
"http.status_code": 402
}Now a UI can pivot from trace to logs, from logs to host metrics, and from a deploy marker to the exact release. Without those fields you are doing textual archaeology.
Metrics tell you where, logs tell you what, traces tell you how
A pragmatic incident flow:
metric spike -> service and endpoint; trace sample -> failing dependency; logs for trace_id -> precise exception
Logs are terrible aggregation engines. Metrics are terrible narrative engines. Traces connect the two. Centralized logging becomes much more valuable when it is a participant in that loop instead of a separate island.
Kubernetes context is not optional in container platforms
Minimum useful metadata:
k8s.namespace.namek8s.pod.namek8s.container.namek8s.deployment.nameor workload equivalent- node name
- image tag or digest
Pod names are high cardinality, so in Loki they often do not belong as stream labels. In Elastic they are fine as indexed keyword fields. This is one of those places where the storage engine changes the data model.
Correlation failures are usually schema drift
One service emits traceId, another trace_id, a third trace.id, and the frontend sends x-request-id while the gateway records request.id. Congratulations: you have all the data and none of the joins.
Pick conventions. ECS in Elastic environments and OpenTelemetry semantic conventions elsewhere are both better than local improvisation.
Field notes
- Include deployment version in every log. Half of incident questions are secretly "did this start with the deploy?"
- Do not log secrets or full payloads to create context. Redact fields at emission.
- Correlation IDs should propagate across queues and async workers, not stop at HTTP boundaries.
- A missing identifier is not a logging library failure; it is usually middleware ordering or context propagation debt.
Was this lesson helpful?