# Correlate

**Correlate** follows one id through every source you can see. Give it a trace id, a request id or a correlation id and it shows every line that carries it, from every service, as one timeline in the order it happened. It is the click to make when a response looked fine and something broke further down: the API's line, the worker's line and the payment service's error, side by side.

## Open it

- **From a log line.** Open a line in the log viewer. If its context has a trace id or a request id, press **Follow trace_id across sources** (or **Follow request_id across sources**). Every other field has a follow button too, so `user_id` or `order_id` works the same way.
- **From a trace.** On a trace's waterfall, press **Logs of this trace**.
- **By pasting an id.** Open **Correlate** in the sidebar (under Analysis), or press <kbd>⌘K</kbd> and paste the id: the command palette offers **Follow … across sources** for anything that looks like an id.

Opened from a line, it looks 15 minutes either side of that line. Opened with a pasted id, it looks at the hour before now. The buttons above the timeline widen it (up to 3 days either side of a line, or the last 7 days). The address of the page holds the id and the window, so **Copy link** gives a teammate the same view.

## What you see

- **The timeline.** Each line shows its time, how long after the first line it came (`+12 ms`, `+1.24 s`), its level, its source and service, and its message. Click a line to see its fields. From there, **Open in** a source shows it in that source's log viewer, and **Follow** on another id in the line (its `request_id`, say) moves to that id.
- **Sources.** One chip per source with its line count and errors. Click a chip to hide or show that source's lines. The link on a chip opens those lines in the source's log viewer.
- **Jump to the first error.** Scrolls to the first error-level line and opens it.
- **Spans of this trace.** For an OpenTelemetry trace id, each source that received spans of the trace shows how many, how long the trace ran, which services took part and how many spans failed, with a link to its waterfall.

At most 500 lines are listed. When an id has more, the source chips still show the true counts, and each chip's link opens the source's own viewer, where you can page through all of them.

## Where the id is looked for

Without a field, Correlate looks under the keys apps usually send an id under:

```
trace_id  traceId  request_id  requestId  req_id  x_request_id  correlation_id  correlationId
```

A key is matched as a string or as a number (`"request_id": 482` matches `482`). Type a field name in the **Field** box to look under one other top-level key instead, for example `order_id`, `user_id` or `session_id`. OpenTelemetry logs already carry `trace_id` (see [OpenTelemetry](https://tailcove.dev/docs/opentelemetry/overview)).

Only the sources you can see are searched: a member limited to some clients' sources finds the id only in those.

## Send the id with every line

Correlate can only join lines that carry the same id. Put one on every line a request writes, in each service, and pass it on to the next service in a header (`traceparent` for OpenTelemetry, or your own `X-Request-Id`).

Laravel (the [Laravel package](https://tailcove.dev/docs/sending-logs/laravel-package)), in a middleware:

```php
$requestId = $request->header('X-Request-Id') ?: (string) Str::uuid();

Log::shareContext(['request_id' => $requestId]);
```

Node.js (the [Node.js client](https://tailcove.dev/docs/sending-logs/node)):

```js
tailcove.info('charge created', { request_id: req.headers['x-request-id'] });
```

Python (the [Python client](https://tailcove.dev/docs/sending-logs/python)):

```python
logger.info("charge created", extra={"request_id": request_id})
```

## From code and AI assistants

The same search is available to scripts as [`GET /api/v1/correlate`](https://tailcove.dev/docs/api/logs#correlate), with a token that has `logs:read`:

```bash
curl -G https://tailcove.dev/api/v1/correlate \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  --data-urlencode "id=4bf92f3577b34da6a3ce929d0e0e4736"
```

AI assistants connected through the [MCP server](https://tailcove.dev/docs/mcp) get it as the `follow_id` tool.

## Good to know

- An id is at most 200 characters, with no line breaks.
- A trace id typed in capitals is read in lower case, as trace ids are sent.
- Fields are read from the top level of a line's context. An id inside a nested object (`{"trace": {"id": …}}`) is not found; send it as a top-level key.
- Each line's fields are shown up to 4,000 characters. Open the line in its source to see all of them.
