feat(pi-bots): alert on the job clock, failed jobs and the SGG preview watchdog (#10) #22
No reviewers
Labels
No labels
ready-for-agent
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bryan/nix-configs!22
Loading…
Reference in a new issue
No description provided.
Delete branch "n10-4-job-alerts"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of #10 (N10.4: alert rules for the preview watchdog's metrics), together with the job clock rules #9 left until the clock wrote its metrics.
What
In
modules/services/pi-bots.nix, beside the existingPiBots*rules, all warnings and each held only while the service reports itself up with a fresh health file (so a stopped or crashed service still raises one alert):PiBotsClockSilent:pi_bots_clock_last_tick_timestamp_secondsover 60 s old for 5 min (the clock ticks every 10 s; 0 means no tick since start).PiBotsJobFailed:pi_bots_job_last_run_failed == 1for 10 min, named byjob_id; clears when the job's next run does not fail. Theforlets a 5-minute job fail once without an alert.PiBotsJobWaiting: a job held back 30 min because its bot is not bridged.PiBotsJobFileUnusable:pi_bots_clock_bad_job_files > 0for 15 min.New option
services.pi-bots.alerts.sggPreviewWatchdog(on for Studio) adds rules for the SGG preview watchdog, a pi-bots job (every 5 min) whose script writessgg-preview-watchdog.prominto the service's metrics directory, which node_exporter already reads:SggPreviewWatchdogSilent: no finished run for 20 min (one run may take ~14 min and the clock skips a slot while one runs, so run ends can be ~19.5 min apart), or no file at all, while the service is up and its clock ticks (a stopped clock isPiBotsClockSilentalone); 5 min.SggPreviewWatchdogBlocked: waiting for Tailscale or unable to read the registry, 30 min.SggPreviewNeedsAttention: a persistent previewfailed,expiredorcleanup_failedfor 15 min (a preview reads failed for a moment while restarted), per preview, withkeep_firing_for15 min so a short gap in the preview list sends no resolved notice for a preview still broken.The last two hold only while the watchdog's own file is fresh, so a stale file raises only
SggPreviewWatchdogSilent. A watchdog run that fails outright isPiBotsJobFailed{job_id="sgg-preview-watchdog"}. A job disabled after a failure keepsPiBotsJobFaileduntil its file is removed or it runs again (its last run stays inclock.db).Docs:
modules/services/AGENTS.md(pi-bots row), README.Tests
scripts/test_pi_bots_service.py(51, was 23):promtool test rulesfor each new rule firing and staying quiet (a short pause of the clock, one failed run followed by a good one, the worst-case gap between watchdog runs, a preview failed for a moment, a short gap in the preview list), each rule's service-down gate (crash and clean stop), the clock gate, the stale-watchdog-file gate, and the opt-in;promtool check metricson the clock's and the watchdog's files as written. Mutations of every threshold,for,keep_firing_for, gate, theabsent()branch and the opt-in each fail a test. The expressions were also run against the live Prometheus.darwin-rebuild build --flake .#studiobuilds; the monitoring, fseventsd, NAS and OpenCode Go suites pass.After
update-systemThe new rules load with health ok. Expect
SggPreviewNeedsAttentionfor the persistent previews that are alreadycleanup_failed(long-standing; Hermes alerted on each once): that is the rule working. They arrive as one grouped notice, by email and in Studio Alerts, repeated every 4 h (Alertmanager'srepeat_interval) until each preview is recovered or removed.Review
A visible Pi reviewer requested changes: two should-fixes (the long-run test did not pin the Silent threshold; the waiting-job and bad-file gates were untested) and six nits (the absent branch's freshness untested; a stopped clock also raised Silent; resolved notices on a list gap; the 4-hourly repeat; a disabled job's failure never clears; the
forcomment). All fixed or documented, each fix with a test that fails without it.