Adds a monitor type for things that can't be probed from outside, like
cron jobs, backups or devices behind NAT (#95). Instead of being checked
by the worker, the monitored service requests
/api/push/<monitor id>/<pushToken>
periodically, and the monitor goes down when no heartbeat was received
for `pushGraceSeconds` (default 300).
{
id: 'backup',
name: 'Nightly backup',
method: 'PUSH',
target: '',
pushToken: '<random string>',
pushGraceSeconds: 300,
}
How it works:
- `pages/api/push/[id]/[token].ts` is an edge API route of the status
page, so no change to the worker deployment is needed. It stores the
time of the last heartbeat in D1 under the key `push:<monitor id>`.
An unknown monitor and a wrong token both get a 404.
- To limit D1 writes, a heartbeat within 30 seconds of the recorded one
is accepted without writing.
- The worker reads that time on every run and reports the monitor up or
down like any other check, so incidents, notifications, grace period
and callbacks all work unchanged. The error message is kept constant
during an outage to avoid error reason change notifications.
- `passwordProtection` doesn't apply to `/api/push/`, heartbeats are
authenticated by the token.
- PUSH monitors have no response time, their latency chart is hidden.
Co-Authored-By: Claude <noreply@anthropic.com>