Commit Graph

4 Commits (1de2a6b5d9260b127ddb983d1ccf2b0ec2cc6083)

Author SHA1 Message Date
jakevis e900bf2873
feat: PUSH (heartbeat) monitors
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>
2026-11-19 10:13:47 -08:00
lyc8503 57a37fd3c1 fix #114: add missing type def 2025-05-31 01:20:32 +08:00
lyc8503 4bcf4173ea misc: run prettier 2025-04-19 21:50:43 +08:00
lyc8503 e2b469c39d fix #12: http basic auth 2024-08-21 16:21:44 +08:00