# Monitoring logs, health and alerts (https://docs.opensequence.dev/docs/self-hosting/observability)

How to watch a running OpenSequence: JSON logs, the health endpoints, the alerts worth setting, runs that need review, and what is not built yet.

OpenSequence reports through structured logs and a few health endpoints. There is no metrics endpoint, so this page shows what to watch and where to read it.

<CodeGroup>

```bash title="curl"
curl $SEQ/v1/admin/engine/health -H "Authorization: Bearer $SEQ_ADMIN_TOKEN"
# {"paused":false,"disabled_channels":[],
#  "queues":[{"queue":"seq_email","depth":3,"oldestMs":1200}],
#  "jobs":{"plan":"2026-10-16T14:09:44.957Z","signals":"…","poll":"…","reap":"…","webhooks":"…","retention":"…"}}

curl $SEQ/v1/engine/health -H "Authorization: Bearer $ADMIN_KEY"
# {"flags":{},"queues":[…],"jobs":{…},"paused":false}
```

```ts title="TypeScript"
import { OpenSequence, OpenSequenceAdmin } from '@opensequence/sdk';

const admin = new OpenSequenceAdmin({ baseUrl: SEQ, adminToken: process.env.SEQ_ADMIN_TOKEN! });
const platform = await admin.engineHealth();

const oseq = new OpenSequence({ baseUrl: SEQ, apiKey: process.env.ADMIN_KEY! });
const project = await oseq.project.health();
```

</CodeGroup>

## Health endpoints [#health-endpoints]

| Where | What it tells you |
|---|---|
| `GET /healthz` | the process is up. Use it for liveness |
| `GET /readyz` | the database answers; on `worker` and `all`, the scheduler also ran a job in the last 2 minutes. `503` with a `reason` otherwise |
| `GET /v1/admin/engine/health` | platform-wide: `paused`, `disabled_channels`, `queues` (depth and oldest ready message per queue), `jobs` (last run of each scheduler job). Operator token |
| `GET /v1/engine/health` | the same plus the project's `flags`. `admin` key. Queue depths are platform-wide numbers |
| `node dist/cli.js health` | the queues and jobs, from inside the container |

## Logs [#logs]

Pino JSON on stdout, at the level set by `SEQ_LOG_LEVEL` (default `info`). Outside `NODE_ENV=production` they are pretty-printed when `pino-pretty` is installed (a source checkout); the image does not ship it, so containers always log JSON.

- Every request line carries `reqId`, the same `req_…` id the API returns in `meta.request_id`. Search by it when a client reports an error.
- Engine lines carry the ids they touched, such as `projectId`, `enrollmentId`, `runId`, `contactId`, `endpointId` or `deliveryId`, so one search follows a contact through the system.
- Every scheduler job logs one line per run, `job plan ran`, with its counts (`claimed`, `advanced`, `requeuedRuns`, …) and `durationMs`. A failing job logs `job <name> failed` with the error.
- The `Authorization` header and fields named `api_key`, `client_secret`, `secret` and `refresh_token` are redacted.

The `plan` job runs every 5 seconds, so `info` is chatty. Use `warn` if you only want problems.

## Alerts worth setting [#alerts-worth-setting]

| Signal | What it means |
|---|---|
| `/readyz` failing on a worker | the scheduler stopped, or the database is unreachable |
| a queue's `depth` growing for ten minutes | the worker is behind, or a provider is failing |
| the `plan` job's last run older than a minute | no planner is running |
| `run.needs_review` webhooks | a text with an unknown outcome waits for a human |
| `run.failed`, or `enrollment.paused` with `step_failed` | a step ran out of retries with no `failed` branch wired |
| `endpoint.disabled` | your own webhook receiver has been down for three days, or its secret can no longer be decrypted |
| `sender.channel_status` with `credentials_needed` | a sender must save their mailbox settings again |
| `5xx` from the API, `INTERNAL_ERROR` in responses | search the logs by the `request_id` |

Oldest-due lag has no endpoint; [Scaling](/docs/self-hosting/scaling) shows the SQL to read it.

## Runs that need review [#runs-that-need-review]

A text whose outcome Allo could not confirm is never retried, because a retry could text the person twice. The run is marked `needs_review`, a `run.needs_review` webhook goes out, and the enrollment stops at that step.

Today you resolve it by hand. Check in Allo whether the text left, then exit the enrollment with `POST /v1/enrollments/{id}/exit`. Re-enrolling starts the sequence again from the start. The `needs-review` list and resolve endpoints described in the architecture document are not built yet.

## Not built yet [#not-built-yet]

- No Prometheus `/metrics` endpoint. `SEQ_METRICS` is accepted and ignored.
- No per-channel circuit breaker.
- An incoming `X-Request-Id` header is not propagated; the service makes its own `req_…` id.
