ZevSight
Open app

API reference

Live tail API reference

Reference for the /v1/tail WebSocket: subprotocol, frames in both directions, resume and close codes, generated from the ZevSight OpenAPI file.

Stream matching events over WebSocket as they arrive.

Stream matching events as they arrive. Guide: Live tail.

Base URL: wss://eu.zevsight.com. Machine-readable: /openapi.yaml.

Open a live tail

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

Live tail over WebSocket.

Upgrade to WebSocket (Sec-WebSocket-Protocol: zevsight.tail.v1). No credential in the URL. Frames are JSON text. See https://docs.zevsight.com/explore/live-tail.

Client → server

  1. TailAuth — first frame, within 5 s, or the socket closes with 4401.
  2. TailSubscribe — start, or change the filter (replaces the previous one).
  3. TailAuth again before the ticket expires, to keep the socket.
  4. {"type":"pause"} / {"type":"resume"}.

Server → client

  • TailLines every ≤75 ms while lines match.
  • TailCaughtUp once, after the catch-up from resume_from.
  • TailLagging when the client cannot keep up.
  • TailError, then close. One exception: an UNAVAILABLE error after a subscribe means the catch-up of recent lines failed; the socket stays open and streams new lines.
  • A TailLagging frame with skipped: -1 after a catch-up means more than 10,000 lines matched since resume_from; fetch the rest with search.

A subscribe with resume_from sends lines with received_at from 2 s before it (the overlap absorbs clock differences between gateways); drop lines whose id is already shown. {"type":"resume"} after a pause catches up from the last line sent, so pausing leaves no gap.

Close codes: 4400 invalid subscribe (bad filter, unknown frame), 4401 unauthenticated or key revoked, 4403 project not readable, 4408 ticket expired (send a fresh TailAuth before exp), 4429 too many tails for the organization.

Authentication: none. The token in the URL is the credential.

Responses

StatusDescription
101Switching protocols. Every frame on the socket, in both directions, is a TailFrame.
426Not a WebSocket upgrade request, or the wrong subprotocol.

Frames

Every frame is a JSON text message with a type.

auth (client → server)

FieldTypeRequiredDescription
type"auth"yes
tokenstringyesEngine ticket, read key or agent key.

subscribe (client → server)

FieldTypeRequiredDescription
type"subscribe"yes
projectsarray of stringyesProject public ids, or [“all”].
qstringSame grammar as /v1/query/logs.
environmentsarray of stringLike env= on search.
resume_fromstring (date-time)received_at of the newest line the client already shows.

lines (server → client)

FieldTypeRequiredDescription
type"lines"yes
linesarray of EventOut
lines[].idstring (uuid)yesUUIDv7. Omit to have one generated.
lines[].environmentstringyesDefault production. Pattern ^[a-z0-9][a-z0-9._-]{0,63}$.
lines[].servicestringyesDefault unknown. Pattern ^[a-z0-9][a-z0-9._-]{0,63}$.
lines[].typestringyesOne of log, heartbeat, check_result.
lines[].tsstring (date-time)yes
lines[].trace_idstringPattern ^[0-9a-f]{32}$.
lines[].span_idstringPattern ^[0-9a-f]{16}$.
lines[].severitystringOne of trace, debug, info, warn, error, fatal.
lines[].attrsobjectUp to 128 keys. Map of string to string (values up to 8192 characters).
lines[].resourceobjectUp to 128 keys. Map of string to string (values up to 8192 characters).
lines[].bodyone of LogBody, HeartbeatBody, CheckResultBodyyes
lines[].body.messagestringyes(LogBody) Truncated above 64 KiB.
lines[].body.fieldsobject(LogBody)
lines[].body.monitor_idstringyes(HeartbeatBody)
lines[].body.statusstringyes(HeartbeatBody) One of start, ok, fail.
lines[].body.duration_msinteger(HeartbeatBody) At least 0.
lines[].body.notestring(HeartbeatBody) Up to 8192 characters.
lines[].body.check_idstringyes(CheckResultBody)
lines[].body.regionstringyes(CheckResultBody)
lines[].body.node_idstringyes(CheckResultBody)
lines[].body.config_versionintegeryes(CheckResultBody)
lines[].body.statusstringyes(CheckResultBody) One of up, down, degraded.
lines[].body.latency_msintegeryes(CheckResultBody) At least 0.
lines[].body.detailobject(CheckResultBody) Map of string to string.
lines[].body.errorstring(CheckResultBody) Short reason when not up; omitted when up.
lines[].body.signaturestringyes(CheckResultBody)
lines[].projectstringyesProject public id.
lines[].received_atstring (date-time)yes

caught_up (server → client)

FieldTypeRequiredDescription
type"caught_up"yes

lagging (server → client)

FieldTypeRequiredDescription
type"lagging"yes
skippedinteger
resume_fromstring (date-time)

error (server → client)

FieldTypeRequiredDescription
type"error"yes
errorobject
error.codestringyesOne of INVALID_REQUEST, UNAUTHENTICATED, NOT_FOUND, PAYLOAD_TOO_LARGE, RATE_LIMITED, QUOTA_EXCEEDED, UNAVAILABLE, INTERNAL_ERROR, WRONG_REGION.
error.messagestringyesA sentence for a person.
error.fieldstring
error.referencestringPresent on INTERNAL_ERROR; quote it to support.
error.endpointstringPresent on WRONG_REGION: the ingest host of the region the credential belongs to.

Example

// Node 22+ or any browser: the WebSocket API is built in.
const ws = new WebSocket('wss://eu.zevsight.com/v1/tail', 'zevsight.tail.v1');

ws.onopen = () => {
  ws.send(JSON.stringify({ type: 'auth', token: process.env.ZEVSIGHT_API_KEY }));
  ws.send(JSON.stringify({
    type: 'subscribe',
    projects: ['all'],
    environments: ['production'],
    q: 'level:>=warn service:api',
  }));
};

ws.onmessage = (msg) => {
  const frame = JSON.parse(msg.data);
  if (frame.type === 'lines') for (const e of frame.lines) console.log(e.ts, e.severity, e.body?.message);
  if (frame.type === 'lagging') console.warn('skipped', frame.skipped, 'lines; resume_from', frame.resume_from);
  if (frame.type === 'error') console.error(frame.error.code, frame.error.message);
};

ws.onclose = (e) => console.log('closed', e.code); // 4401 auth, 4403 project, 4429 too many tails

Built 29 November 2026 · View as Markdown