---
title: ZevSight CLI
description: Search and tail logs, send lines from any program, ping heartbeats from cron and act on alerts from your terminal with the zevsight command.
url: https://docs.zevsight.com/tools/cli
---

# ZevSight CLI

> Search and tail logs, send lines from any program, ping heartbeats from cron and act on alerts from your terminal with the zevsight command.

`zevsight` is ZevSight on the command line: search and live tail, send lines from stdin, heartbeat pings for cron jobs, alerts, incident notes and uptime checks. It works the same for people, scripts and AI agents, and every command can print JSON.

## Install

```bash
npm install -g @zevsight/cli
zevsight --version
```

Or run it without installing:

```bash
npx @zevsight/cli logs search timeout --since 1h
```

Node.js 18 or newer. `zevsight update` updates it with the tool you installed it with (npm, pnpm, yarn or bun).

## Log in

The CLI uses an [API key](/workspace/api-keys) (`zsr_…`). A key belongs to one workspace and never reaches more than the person who created it.

```bash
zevsight login
```

This opens **API keys** in the dashboard with **Used by: CLI** chosen. Pick its reach and permission, create it, and paste the key at the prompt. Choose **read** to search and tail, or **respond** to also acknowledge, resolve and snooze alerts and add incident notes.

If you already have a key, paste it at a hidden prompt, or pipe it in:

```bash
zevsight login --with-token
zevsight login --with-token < key.txt
```

The key is never taken from the command line, so it stays out of your shell history. It is saved in your user config folder, readable only by you.

```bash
zevsight whoami          # workspace, key, permission, reach, projects and expiry
zevsight auth status     # every saved login, and whether its key still works
zevsight logout          # forget the key on this computer
```

`logout` only forgets the key here. To stop it everywhere, revoke it in **API keys**.

### Several workspaces

Log in once with a key from each workspace. The last one you logged in to is active.

```bash
zevsight workspace list
zevsight workspace use acme
zevsight -w globex alerts list     # another workspace for one command
```

### CI and agents

Set `ZEVSIGHT_API_KEY` instead of logging in. It overrides any saved login:

```bash
ZEVSIGHT_API_KEY=<API_KEY> zevsight --json alerts list
```

## Search logs

```bash
zevsight logs search '"connection reset"' --since 2h
zevsight logs search 'attrs.route:/v1/pay*' --service checkout --env production --level error
zevsight logs search timeout --from 2026-11-28 --to 2026-11-29T06:00:00Z --limit 500
```

The query uses the same [search syntax](/explore/search-syntax) as the explorer. The flags are shortcuts for common terms:

| Flag | Means |
|---|---|
| `-s, --service api,worker` | `service:api,worker` |
| `-e, --env production` | Only these environments |
| `-l, --level warn` | Warn and above. `--level error,fatal` is exactly those levels. |
| `-p, --project shop` | Project names or `prj_…` ids, comma separated. Default: every project the key reads. |
| `--since 2h` | How far back: `15m`, `2h`, `7d` (default `1h`) |
| `--from`, `--to` | A duration ago, a date (`2026-11-29`) or an RFC 3339 time |
| `-n, --limit 500` | How many lines (default 100, up to 10,000) |
| `--ids` | Show each line's id, for `logs context` |

Lines print oldest first, so the newest is at the bottom, like `tail`. Use `--newest-first` to flip the order. `zevsight project use <name>` sets a default project for the workspace.

The lines around one event, from the same service and environment:

```bash
zevsight logs context 01937a4e-8c2f-7d3a-9b1e-4f6a2c8d0e5b --before 50 --after 20
```

## Live tail

```bash
zevsight tail
zevsight tail --service api --env production --level warn
zevsight tail 'attrs.user_id:42'
zevsight --json tail --service api | jq -r .body.message
zevsight tail --for 30s
```

`tail` takes the same query and flags as `logs search`. If the connection drops, it reconnects with backoff and resumes from the last line it showed, without showing a line twice. See [Live tail](/explore/live-tail). Press Ctrl-C to stop, or use `--for` to stop after a while.

## Send lines

`zevsight send` sends lines from stdin with an [ingest token](/workspace/api-keys#ingest-tokens) (`zsi_…`), which you create on a service's **Connect** panel. It batches like the [Node.js SDK](/send/nodejs): up to 500 lines or 1 MiB per request, gzip, retries with backoff, and an `Idempotency-Key`, so a retry never stores a line twice.

```bash
export ZEVSIGHT_INGEST_KEY=<INGEST_TOKEN>

./nightly-export.sh 2>&1 | zevsight send --service exports --env production
node server.js | zevsight send --service api --tee
tail -F /var/log/app.log | zevsight send --service app --level info
zevsight send --service deploys --level warn "Rolled back 2.4.1"
```

A line that is a JSON object (pino, bunyan, winston and most JSON loggers) is mapped field by field:

| In the line | Becomes |
|---|---|
| `msg` or `message` | The message |
| `level`, `severity` (a name or pino's number) | The level |
| `time`, `ts`, `timestamp` | The event time |
| `trace_id`, `span_id` | The trace and span |
| `hostname`, `pid` | Resource `host.name`, `process.pid` |
| Other strings, numbers, booleans | Attributes |
| Objects and arrays | Fields |

Any other line is sent as written. `--text` sends JSON lines as text too. `--level` sets the level of lines that don't carry one, and `--tee` also prints each line, so you still see the output.

| Flag | |
|---|---|
| `-s, --service` | Service (default `ZEVSIGHT_SERVICE`, else `unknown`) |
| `-e, --env` | Environment (default `ZEVSIGHT_ENVIRONMENT`, else `production`) |
| `--endpoint` | Ingest host (default `ZEVSIGHT_ENDPOINT`, else `https://ingest.zevsight.com`) |

`send` exits `1` if any line wasn't stored, and says why. See [Limits and batching](/send/limits).

## Heartbeats from cron

The heartbeat's token, or its whole ping URL, is the credential, so these commands need no login. See [Heartbeats from cron](/send/heartbeats).

```bash
zevsight heartbeat ping <PING_TOKEN>
zevsight heartbeat ping <PING_TOKEN> -m "exported 4,210 rows"
zevsight heartbeat start <PING_TOKEN>
zevsight heartbeat fail <PING_TOKEN> -m "disk full"
```

`heartbeat run` wraps a command. It pings start, runs the command with its output passed through, then pings success, or failure with the exit code and the end of the output as the note:

```bash
# m h dom mon dow  command
0 3 * * *  zevsight heartbeat run <PING_TOKEN> -- /usr/local/bin/backup.sh --full
```

| Flag | |
|---|---|
| `--timeout 2h` | Stop the command after this long and report a failure |
| `--no-start` | Don't send the start ping |

It exits with the command's own exit code (`128 + n` when a signal stopped it, `127` when it couldn't start), whatever happens to the pings, so cron and CI see what the job did. A ping that can't be sent is reported on stderr and never fails the job.

## Alerts and incidents

```bash
zevsight alerts list                         # open alerts
zevsight alerts list --all                   # and each rule's last resolved alert
zevsight alerts ack 0193a4e8                 # the id, or its start as the list shows it
zevsight alerts snooze 0193a4e8 --for 1h     # 5m to 24h, default 30m
zevsight alerts resolve 0193a4e8
```

Add a Markdown note to an incident's timeline. It is also copied to a connected [ZevThread](/respond/zevthread) thread:

```bash
zevsight incidents note inc_9KqP2mX7vN4bR8tW3yZ6c "Rolled back; error rate is normal again"
zevsight alerts note 0193a4e8 -F update.md     # on the alert's incident, from a file (- for stdin)
```

> **Note: Respond permission**
>
> Acknowledging, resolving, snoozing and notes need a key with the **respond** permission. A **read** key gets a clear refusal. See [Alerts and rules](/respond/alerts) and the [Notes API](/api/notes).

## Uptime checks

```bash
zevsight checks status            # state, 24 h / 7 d / 30 d uptime, p95 latency and regions
zevsight checks status --down     # only checks that are down or degraded
```

`checks status` exits `1` when a check is down, so a script can act on it.

## Scripts and agents

- `--json` on any command prints JSON. `zevsight --json tail` prints one event per line.
- Errors go to stderr. With `--json` they are JSON too: `{ "error": { "code", "message", … } }`.
- Exit codes:

| Code | Means |
|---|---|
| `0` | Done |
| `1` | Refused or failed |
| `2` | Bad usage (an unknown flag, a bad duration) |
| `3` | Not found |
| `4` | Not logged in, or the key doesn't work |

`heartbeat run` exits with the wrapped command's code instead.

## Environment variables

| Variable | |
|---|---|
| `ZEVSIGHT_API_KEY` | Use this API key instead of a saved login |
| `ZEVSIGHT_INGEST_KEY` | Ingest token for `zevsight send` |
| `ZEVSIGHT_SERVICE`, `ZEVSIGHT_ENVIRONMENT` | Defaults for `send` |
| `ZEVSIGHT_ENDPOINT` | Ingest host (default `https://ingest.zevsight.com`) |
| `ZEVSIGHT_ENGINE_URL` | Query and live tail host (default: the key's region, such as `https://eu.zevsight.com`) |
| `ZEVSIGHT_API_URL` | Control-plane API (default `https://api.zevsight.com`) |
| `ZEVSIGHT_CONFIG_DIR` | Keep logins in another folder |
| `ZEVSIGHT_NO_UPDATE_NOTIFIER` | `1` turns off the once-a-day update notice |
| `NO_COLOR` | Plain output |

## Security

- Keys are stored in your user config folder: folder `0700`, file `0600`. `zevsight auth status` shows where.
- Keys only travel over HTTPS. Plain HTTP is refused except to `localhost`.
- Live tail sends the key in its first WebSocket message, never in the URL.
- The engine records each key's last use as "ZevSight CLI", shown on the key in **API keys**.
