Skip to main content

Module monitor

Module monitor 

Source
Expand description

Uptime monitors: what users see of an org’s apps, checked from outside the app every interval, with history, incidents and notifications.

A monitor is an HTTP(S) request (status range, keyword present or absent, headers from secrets, redirects, a certificate expiry warning), a TCP connect, or an app monitor that follows an app by reference: its served domain’s public URL, or with no domain the app’s own endpoint. When the domain sits behind Cloudflare Access without a service token, it is checked hop by hop (chain): Cloudflare’s edge, the org’s tunnel, and the ingress. A service monitor does the same for one service of a compose stack. Every app with a served domain gets an app monitor of its own (app-<name>, auto), and every compose stack service with one a service monitor (stack-<stack>-<service>, auto, see auto), unless the org opts out or excludes it.

Checks run in the daemon that runs the org’s apps (service); state, thresholds and flap damping are in state, the probes in probe, history in store. Channels hear monitor.down, monitor.up and monitor.cert_expiring through the notifier like every other event.

Definitions are kept in <state>/orgs/<org>/monitors/monitors.json, the org’s settings beside them in settings.json.

Re-exports§

pub use service::Monitors;

Modules§

auto
Monitors isb makes by itself: which apps and compose stack services get one of their own, what it is called, and how the org’s list follows them.
heartbeat
The dead man’s switch: a GET to an outside URL every interval (healthchecks.io, Better Stack, Uptime Kuma’s push monitors, cronitor, or anything that alerts when the pings stop), so someone hears about it when the host, incusd’s machine or the daemon itself is gone, which no event from the daemon can say.
probe
The probes: one HTTP(S) request or TCP connect, under a deadline, held to net’s address policy.
service
The monitoring service of a daemon: definitions, the scheduler, the workers that run checks, and the events they raise.
state
A monitor’s state machine: failure and recovery thresholds (hysteresis), one notification per change (de-duplication) and flap damping. No I/O, so every rule is tested on its own.
store
Check history, per org, in SQLite (<state>/orgs/<org>/monitors/ monitors.db), the bundled rusqlite the metrics history uses.

Structs§

Header
A request header: a plain value, or the value of org secret secret (read at check time, never shown).
Monitor
One monitor. Fields that do not apply to its type are refused.
Settings
An org’s monitoring settings.

Enums§

Kind

Constants§

ACCESS_ID_SECRET
The org secrets an app monitor presents to Cloudflare Access, when both exist and the monitor sets no Access headers of its own.
ACCESS_SECRET_SECRET
AUTO_PREFIX
The prefix of an app’s own monitor.
MAX_PER_ORG
Monitors per org at most.
MIN_INTERVAL
The shortest interval, seconds.
STACK_PREFIX
The prefix of a compose stack service’s own monitor.

Functions§

dir
Where an org’s monitors live.
human
A duration in words: 4m 12s, 2h 5m, 3d 1h.
parse_status
Parse 200-399, 200,204,300-399 into inclusive ranges.
validate_name
A monitor name: [a-z0-9-], a letter first, at most 63.
validate_service_name
A compose service’s name, as a service monitor refers to it.