A correlation ID, often called a request ID, is a unique value that is assigned when a request enters a system and is then passed to every service, queue message and log entry that handles this request. Searching for the ID returns all related events across components. In modern distributed systems the W3C Trace Context trace ID serves the same purpose in a standardized way and additionally links logs to traces.
What is a correlation ID?
In a monolith, the log lines of one request are usually close together. In a system of microservices, a single user action can touch an API gateway, several services, a message queue and background workers, and each of them writes its own logs. A correlation ID ties these pieces together: it is generated once, carried along with the request and written into every log entry. When an error occurs, you search for one value and get the complete story across all components.
The terms correlation ID, request ID and transaction ID are used almost interchangeably. Some teams distinguish between a request ID per single HTTP call and a correlation ID that spans a whole business transaction, but there is no binding standard for this distinction.
Common headers
Correlation IDs travel as HTTP headers or message attributes. Widely used names are:
X-Request-ID, which proxies such as NGINX can generate with the variable$request_id.X-Correlation-ID, a popular convention in enterprise and messaging environments.X-Amzn-Trace-Id, which AWS load balancers add to incoming requests.traceparentfrom the W3C Trace Context standard, which carries a trace ID and is understood by OpenTelemetry and most tracing tools.
The X- prefix headers are conventions, not standards, so it pays to agree on one name across all teams.
Correlation ID vs. trace ID
A trace ID is a standardized correlation ID with more structure. While a classic correlation ID only groups log lines, a trace ID belongs to a trace made of spans with parent child relationships, timings and status. That allows you to see not only which services were involved, but also in which order and where the time was spent. If you use OpenTelemetry, the most practical approach is to write the active trace ID and span ID into each log record instead of maintaining a separate ID. A custom correlation ID can still be useful as a business key, for example an order number, which you can add as a span attribute or carry as W3C Baggage.
How propagation works
A correlation ID is only useful if every hop passes it on. This is context propagation:
- Create at the edge: the gateway or first service generates an ID, typically a random UUID, if none is present.
- Store in request context: the service keeps the ID in a request scoped context, such as the MDC in Java logging frameworks,
contextvarsin Python orAsyncLocalStoragein Node.js, so every log call picks it up automatically. - Forward on outgoing calls: HTTP clients, gRPC interceptors and message producers add the ID to outgoing headers or message attributes.
- Restore in async work: consumers and background jobs read the ID from the message and put it back into their context before processing.
Gaps often appear at thread pools, asynchronous callbacks and queues. OpenTelemetry instrumentation handles many of these cases for trace context automatically; our article on incomplete distributed traces describes where propagation typically breaks.
Correlation IDs in logs
To be searchable, the ID belongs in a dedicated field of a structured log, not somewhere in the message text:
{"timestamp": "2026-11-05T09:14:03.512Z", "level": "ERROR",
"service": "payment", "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736",
"correlation_id": "c0a8e1f2-7b3d-4e8a-9f21-5d6c7e8f9a0b",
"message": "card authorization failed"}
With central log aggregation, a filter on that field returns every event of the request across services. More guidance is in our article on structured logging best practices.
Best practices
- Use one header name and one log field name across all services.
- Generate random, unique IDs and never put personal data such as user names or e-mail addresses into them.
- Treat incoming IDs from external clients as untrusted: validate format and length, or generate your own and keep the external one as a separate attribute.
- Return the ID in the response, so support teams can ask users for it when something goes wrong.
- Prefer the W3C trace ID where OpenTelemetry is in place, so logs and traces share the same key.
How Obseria helps
Obseria ingests logs and traces through OpenTelemetry and links log entries that carry a trace ID to their trace automatically, so you can jump from an error log to the full request in distributed tracing and back. In log analytics you can filter on custom correlation ID fields across all services. The Obseria Pipeline can parse and enrich logs at ingest, for example to extract an ID from legacy log formats, error tracking shows the affected requests per error, and Obseria Intelligence helps summarize what happened along a correlated request.