feat: heartbeat monitors #75

Merged
Sebi merged 2 commits from feat/heartbeats into main 2026-11-22 11:11:58 +00:00
Owner
  • New monitor type heartbeat: no target, no regions; the target column holds a generated secret token (unique index), the console and API show ping_url = <public URL>/hb/<token>.
  • GET|HEAD|POST /hb/:token records a success, /hb/:token/fail a failure (message from ?msg= or POST body, 2000 bytes read, 500 stored). Plain-text answers for curl/wget, rate-limited per token, outside session/CSRF. Paused monitors accept pings and record nothing.
  • Deadlines: RunHeartbeats checks every 10 s on one replica (Redis lock); overdue = latest result or last change of the monitor + interval + grace (config.grace_seconds, default 60). A recorded failure restarts the wait, so a silent job fails once per period.
  • Results go through evaluateResults under the pseudo-region heartbeat, so confirmations (default 1 for heartbeats), maintenance windows and notifications behave like for checks.
  • The token is a capability: readers get neither target nor ping URL (API, dashboard, monitor page); editors see the URL with curl examples.
  • Editor hides target, timeout and regions for heartbeats and shows the grace period.

Closes #27

🤖 Generated with Claude Code

https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3

- New monitor type `heartbeat`: no target, no regions; the target column holds a generated secret token (unique index), the console and API show `ping_url` = `<public URL>/hb/<token>`. - `GET|HEAD|POST /hb/:token` records a success, `/hb/:token/fail` a failure (message from `?msg=` or POST body, 2000 bytes read, 500 stored). Plain-text answers for curl/wget, rate-limited per token, outside session/CSRF. Paused monitors accept pings and record nothing. - Deadlines: `RunHeartbeats` checks every 10 s on one replica (Redis lock); overdue = latest result or last change of the monitor + interval + grace (`config.grace_seconds`, default 60). A recorded failure restarts the wait, so a silent job fails once per period. - Results go through `evaluateResults` under the pseudo-region `heartbeat`, so confirmations (default 1 for heartbeats), maintenance windows and notifications behave like for checks. - The token is a capability: readers get neither target nor ping URL (API, dashboard, monitor page); editors see the URL with curl examples. - Editor hides target, timeout and regions for heartbeats and shows the grace period. Closes #27 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Sebi added this to the M8 External Sources milestone 2026-11-22 10:36:28 +00:00
Sebi added 2 commits 2026-11-22 10:36:30 +00:00
Refs #27

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
A heartbeat monitor has a secret ping URL instead of a target and
regions. Jobs call it with GET, HEAD or POST after each run, or /fail
with an optional message. When no ping arrives within the interval plus
a grace period, a failure is recorded and evaluated like a checker
result, so confirmations, maintenance and notifications apply. One API
replica at a time checks deadlines. The URL is shown only to members who
may edit the monitor, since it can report the job healthy.

Closes #27

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Sebi merged commit 8aaac10504 into main 2026-11-22 11:11:58 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ZB-Server/uptimesebi#75