Add heartbeat pings for the alert check and the nightly backup #19

Merged
patrick merged 2 commits from feat/heartbeat into main 2026-10-30 15:35:17 +00:00
Owner

Summary

Every alert depends on kernelwatch-alerts.timer running on the dashboard host. If
that host is down or the timer breaks, nothing says so. Heartbeats let an
external monitor (healthchecks.io, Uptime Kuma push) alert when pings stop.

  • heartbeat_url: GET after every alert check that sent its notifications
    without failures (every 5 min). Also pinged with no ntfy_url, since the
    timer is alive. Skipped when deliveries failed, so a broken alert pipeline is
    noticed too; a crashed check sends nothing.
  • backup_heartbeat_url: GET after each successful scheduled-backup. A failed
    run, a manual kernelwatch backup, or a timer that never ran sends nothing.
  • A failing heartbeat is logged (status or error type, never the URL, which is a
    secret) and never fails the check or backup. 10s timeout, redirects not
    followed, any 2xx is success, query strings allowed (Uptime Kuma).
  • kernelwatch test-heartbeat pings each configured URL once.
  • Config validation for both URLs; README section with monitor settings (alerts:
    5 min / 20 min grace; backup: 1 day / a few hours) and a note to notify by a
    route that doesn't depend on the dashboard host.

Testing

make test: 202 tests pass (19 new), against a real local HTTP server: URL and
query intact, non-2xx/redirect/refused/timeout all fail without leaking the URL,
what each command pings and when, a dead heartbeat never changes an exit code,
test-heartbeat, and config validation. Mutations (ping after failed
deliveries, backup never pings, follow redirects, leak error text) were each
caught.

Not run: a ping to a real healthchecks.io monitor; use
sudo kernelwatch test-heartbeat after deploying.

🤖 Generated with Claude Code

## Summary Every alert depends on kernelwatch-alerts.timer running on the dashboard host. If that host is down or the timer breaks, nothing says so. Heartbeats let an external monitor (healthchecks.io, Uptime Kuma push) alert when pings stop. - `heartbeat_url`: GET after every alert check that sent its notifications without failures (every 5 min). Also pinged with no `ntfy_url`, since the timer is alive. Skipped when deliveries failed, so a broken alert pipeline is noticed too; a crashed check sends nothing. - `backup_heartbeat_url`: GET after each successful `scheduled-backup`. A failed run, a manual `kernelwatch backup`, or a timer that never ran sends nothing. - A failing heartbeat is logged (status or error type, never the URL, which is a secret) and never fails the check or backup. 10s timeout, redirects not followed, any 2xx is success, query strings allowed (Uptime Kuma). - `kernelwatch test-heartbeat` pings each configured URL once. - Config validation for both URLs; README section with monitor settings (alerts: 5 min / 20 min grace; backup: 1 day / a few hours) and a note to notify by a route that doesn't depend on the dashboard host. ## Testing `make test`: 202 tests pass (19 new), against a real local HTTP server: URL and query intact, non-2xx/redirect/refused/timeout all fail without leaking the URL, what each command pings and when, a dead heartbeat never changes an exit code, `test-heartbeat`, and config validation. Mutations (ping after failed deliveries, backup never pings, follow redirects, leak error text) were each caught. Not run: a ping to a real healthchecks.io monitor; use `sudo kernelwatch test-heartbeat` after deploying. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
patrick added 2 commits 2026-10-30 15:33:26 +00:00
heartbeat_url is pinged after every alert check that sent its notifications
without failures, and backup_heartbeat_url after every successful nightly
backup, so an external monitor (healthchecks.io, Uptime Kuma) notices when the
alert timer or the backup stops running. A failing heartbeat is logged without
the URL and never fails the work it reports on. kernelwatch test-heartbeat
pings each configured URL once.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Document the heartbeat monitor setup
CI / tests (Python 3.10) (pull_request) Successful in 24s
CI / tests (Python 3.11) (pull_request) Successful in 24s
CI / tests (Python 3.12) (pull_request) Successful in 24s
CI / tests (Python 3.13) (pull_request) Successful in 24s
CI / lint (pull_request) Successful in 4s
55a9766418
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
patrick merged commit 9d80d3ea4c into main 2026-10-30 15:35:17 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: patrick/kernel-automation#19