Skip to main content
Monitors are experimental. The API, CLI and storage may change between releases.

Which page do I read?

Use monitors to probe an endpoint, a TCP port or a certificate from the control plane. They are experimental and off by default. To learn whether the whole server is down, use the off-host heartbeat, which an outside service watches. External monitoring compares the two and the public status page. A monitor probes an endpoint on a schedule from the control plane and records the result. The monitor kinds are http, tcp, heartbeat and tls, with a result history and hourly rollups. A down monitor is reported by the monitor_down alert rule. Internal incidents and the status page link are opt-in. The feature is off by default. When APP_MONITORS_ENABLED is not true, the /api/v1/monitors routes answer 404 and no scheduler runs.

Kinds

  • http: method (GET, HEAD, POST, PUT), optional headers, accepted status codes or ranges (default 200 to 399), an optional contains keyword searched in the first bytes of the body, and a timeout. Redirects are not followed unless asked for, up to a server limit.
  • tcp: a host and port. The check passes when the connection completes within the timeout.
  • heartbeat: a cron job pings the monitor instead of the other way round. See Cron heartbeat.
  • tls: a certificate expiry check on a host and port. See TLS expiry.
Header values are stored encrypted with the same secret store as app secrets. They are never returned by the API or the CLI, and results keep only a short failure class such as timeout or status_mismatch, never a body or header value.

Network safety

Every connection, including redirects, goes through the outbound address guard. Private, loopback and link local addresses are refused unless the control plane has explicitly allowed private outbound targets. A refused target shows as blocked_address and is rejected at create time.

Results

Results are written in batches, with the hourly rollup updated in the same transaction. Raw results are kept for a short window and rollups for much longer. Pruning runs in small batches so it does not hold the database write lock.

Settings

All limits are environment variables on the control plane. Durations use Go syntax such as 30s or 48h.

API

  • GET /api/v1/monitors, POST /api/v1/monitors, DELETE /api/v1/monitors/{id}
  • GET /api/v1/monitors/{id}/results?window=24h&limit=100 returns recent raw results and hourly rollups.
Reading needs read access and changing needs write access on the monitors resource. Creating and deleting are recorded in the audit log.

Internal incidents

With APP_INCIDENTS_ENABLED, GET /api/v1/incidents, GET /api/v1/incidents/{id}, POST /api/v1/incidents (promote an alert rule: {"source":"alert","rule_id":"..."}), POST .../ack, POST .../resolve and POST .../notes manage them. Otherwise they answer 501. Reading needs the read:sensitive ability because timelines carry probe detail; changes need write and are audited. GET /api/v1/status-page/incidents returns published incidents only, for every caller. PUT /api/v1/incidents/{id}/draft stores the public title, body, and optionally status, impact (none, minor, major, critical) and component_ids (existing status page components; omit to keep the stored list). POST .../publish is the only way an incident reaches the public page. It needs the updated_at you reviewed, answers 409 if the incident changed since, and 422 if the draft title or body is empty. There is no unpublish. From the CLI:
publish fetches the incident, refuses an empty draft or an already published incident before sending anything, and sends the updated_at it just fetched. Pass --updated-at with the value from show to refuse if the incident changed after you reviewed it.

Postmortems

A resolved incident can carry one structured postmortem: summary, impact, root cause, resolution and action items, plus the impact window and the alerts that fired.
  • POST /api/v1/incidents/{id}/postmortem/draft creates the draft. The impact window runs from the earliest recorded outage to the resolve time, and the alert list holds the alert rule or monitors already recorded on the incident. Running it again refreshes those two and keeps the text. It answers 409 until the incident is resolved.
  • PUT /api/v1/incidents/{id}/postmortem edits summary, impact, root_cause, resolution and action_items. Only the fields you send change, so two people editing different fields do not overwrite each other. Control characters (other than newline and tab) and bidi override characters answer 400.
  • POST /api/v1/incidents/{id}/postmortem/publish needs a summary and a root cause (422 otherwise). Publishing is final: every later edit, draft or publish answers 409, also when two requests race. An incident with a published postmortem is skipped by retention cleanup, and deleting it answers 409.
  • GET /api/v1/incidents/{id}/postmortem reads it (404 when there is none yet).
Access matches the rest of the incident API: reading needs read:sensitive, writing needs write, and writes are audited. APP_INCIDENT_POSTMORTEM_FIELD_MAX (default 8000 bytes) caps each text field and action item, and APP_INCIDENT_POSTMORTEM_ACTION_ITEMS_MAX (default 50) caps the list, and APP_INCIDENT_POSTMORTEM_BODY_MAX (default 1 MiB) caps one edit request (413 above it). All three are runtime settings and apply live. Every write answers 409 until the incident is resolved. The dashboard shows the postmortem under a resolved incident and renders every field as plain text.
A monitor can open a public status page incident while it is confirmed down and resolve it on recovery. It is off by default, so existing monitors do not change.
  • Turn it on with the “Open status page incidents” checkbox, levelrail-cli monitors create --status-link, or levelrail-cli monitors update <id> --status-link. The API field is status_link (PATCH /api/v1/monitors/{id}).
  • The incident lists the status page components of kind monitor that target this monitor, with the impact from APP_MONITOR_LINK_IMPACT (minor or major, default major). Add the monitor as a component to see its state change.
  • One incident per outage: a repeated down never opens a second one, and a monitor that flaps back inside the recovery period keeps the same incident.
  • Confirmation: APP_MONITOR_LINK_CONFIRM_FAILURES (default 1) failed checks, or --link-confirm per monitor. Recovery: APP_MONITOR_LINK_RECOVERY_PERIOD (default 2m) of continuous health, or --link-recovery per monitor. APP_MONITOR_LINK_SWEEP_INTERVAL (default 30s) sets how often both are re-evaluated.
  • No incident opens while an active silence or maintenance window covers the monitor, or while an operator incident is already open on its component.
  • Timeline entries are written by system and start with “[Automated]”. Open and resolve write audit rows (monitor_incident.opened, monitor_incident.resolved).
  • Alert channels are notified by the existing monitor_down rule, unchanged. That rule is a critical default, added when APP_MONITORS_ENABLED is true.

Cron heartbeat

A heartbeat monitor has an expected interval and a grace period (default APP_MONITOR_HEARTBEAT_GRACE). Creating it returns a secret ping path once; only its SHA-256 hash is stored.
  • GET or POST /api/v1/heartbeat/<token>: success. Marks the monitor up at once.
  • /start before the job: counts as alive, so a long job is not late. It does not clear a failure.
  • /fail after a failed job: marks the monitor down at once with reason job_failed.
  • No ping within interval plus grace: down with reason heartbeat_missed. The next ping brings it back up.
The route needs no auth header. It answers 204, or 404 for any unknown token, wrong monitor kind, disabled monitor or unknown suffix, after a minimum response time. Requests are rate limited per client address and bodies are capped. Rotate a leaked URL with levelrail-cli monitors rotate-token <id> or POST /api/v1/monitors/{id}/rotate-token; the old URL stops working at once. The dashboard shows a copyable curl line when the monitor is created. Heartbeats feed the same status page link and monitor_down alert rule as the other kinds.

TLS expiry

A tls monitor connects to host:port (default 443), verifies the chain against the system roots and reports the whole days left in the result code. Under the warning threshold it is degraded (still up, reason cert_expiring); under the critical threshold it is down (cert_expiring_critical). An untrusted or mismatched chain is down with cert_invalid, an expired one with cert_expired; verification is never skipped. Per-monitor warn_days and crit_days override APP_MONITOR_TLS_WARN_DAYS and APP_MONITOR_TLS_CRIT_DAYS. The target goes through the same address guard as tcp, so internal hosts are refused unless the private-address opt-in is set.

Pause and resume

PATCH /api/v1/monitors/{id} accepts {"enabled": false} to pause a monitor and {"enabled": true} to resume it. A paused monitor is not probed and the schedule changes at once. Fields left out of the body are unchanged.
Last modified on November 10, 2026