---
title: Live tail
description: Follow matching log lines as they arrive, in the dashboard or over the /v1/tail WebSocket, with pause, resume and catch-up.
url: https://docs.zevsight.com/explore/live-tail
---

# Live tail

> Follow matching log lines as they arrive, in the dashboard or over the /v1/tail WebSocket, with pause, resume and catch-up.

Live tail streams lines that match your scope and query within moments of arriving at ZevSight.

## In the dashboard

- Live is on by default for relative ranges (except Yesterday). Press `L` to turn it on or off. Turning it on with an absolute range switches the range to the last 15 minutes.
- Live runs on the **Lines** tab only.
- **Follow.** The list follows the newest line. Scroll up to stop following without pausing the stream. A "↓ N new lines" pill appears; press `End` or the pill to return.
- **Pause.** Press `Space`. While paused, the control shows how many new lines arrived. Resume catches up from where you paused, so nothing is skipped.
- If lines arrive faster than the browser can show, the explorer says "Showing a sample" with the rate. Pause, or narrow the query, to see every line. The skipped lines are stored; search for them.
- The dashboard reconnects on its own if the connection drops, and catches up from the newest line it has.

## Over the API

`WS wss://eu.zevsight.com/v1/tail`

Open a WebSocket with the subprotocol `zevsight.tail.v1`. Do not put the credential in the URL. Send it in the first frame.

```js
const ws = new WebSocket('wss://eu.zevsight.com/v1/tail', 'zevsight.tail.v1');
ws.onopen = () => {
  ws.send(JSON.stringify({ type: 'auth', token: '<API_KEY>' }));
  ws.send(JSON.stringify({ type: 'subscribe', projects: ['all'], q: 'service:api level:>=error' }));
};
ws.onmessage = (m) => {
  const f = JSON.parse(m.data);
  if (f.type === 'lines') f.lines.forEach((e) => console.log(e.ts, e.body?.message));
};
```

### Client frames

| Frame | When |
|---|---|
| `{"type":"auth","token":"<API_KEY>"}` | First, within 5 seconds, or the socket closes with `4401`. Any API key (`zsr_…`) can tail. |
| `{"type":"subscribe","projects":["all"],"q":"…","environments":["production"],"resume_from":"<RFC 3339>"}` | Starts the stream, or replaces the filter. `q` uses the [search syntax](/explore/search-syntax). |
| `{"type":"pause"}`, `{"type":"resume"}` | Pause and resume. Resume catches up from the last line sent. |

Each client frame is at most 64 KiB.

### Server frames

| Frame | Meaning |
|---|---|
| `lines` | Up to 500 events, sent at least every 75 ms while lines match. |
| `caught_up` | Sent after every subscribe, once the catch-up is done. |
| `lagging` | You are not keeping up. `skipped` lines were left out; search from `resume_from` to fill the gap. |
| `error` | `{code, message}`, then the socket closes. One exception: `UNAVAILABLE` right after a subscribe means the catch-up failed, and the socket keeps streaming new lines. |

### Resume after a disconnect

Subscribe with `resume_from` set to the `received_at` of the newest line you have. The server sends lines from 2 seconds before it, to absorb clock differences, so drop lines whose `id` you already have. The catch-up covers at most 10,000 lines. Beyond that you get `lagging` with `skipped: -1`; fetch the rest with [search](/api/reference/query).

### Close codes

| Code | Meaning |
|---|---|
| `4400` | Invalid subscribe: bad filter or unknown frame |
| `4401` | Not authenticated, or the key was revoked (keys are rechecked every second) |
| `4403` | A project in the subscribe is not readable with this key |
| `4408` | Session expired |
| `4429` | Too many live tails open for the workspace (the limit is 50) |

Full frame schemas: [Live tail API reference](/api/reference/live-tail).
