monitoring: alert on containers failing their healthcheck #394
No reviewers
Labels
No labels
audit-work
bug
docs
general-admin
major-upgrade
needs-vps-sync
new-service
on-hold
outside-work
post-podman
renovate
upstream
vps
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
mysticalsoap/docker!394
Loading…
Reference in a new issue
No description provided.
Delete branch "monitoring/unhealthy-alert"
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?
Problem
A container that is running but failing its own Docker healthcheck alerts nothing. The blackbox internal probes only cover HTTP liveness, and Monitoring.md says so. Closes #126.
Fix
No new exporter or socket proxy: cAdvisor v0.55.1 (already running) exports
container_health_statefor every container, and Prometheus already has it for all 80 running ones (60 at1, 20 at-1for no healthcheck). One alert rule,ContainerUnhealthy, oncontainer_health_state{name!=""} == 0for 6m,severity=critical,category=containers(routes tohomelab-containers).The 6m is because cAdvisor reports
0for bothunhealthyandstarting, so thefor:has to outlast the longeststart_periodin the stack (crowdsec, 300s). No autoheal, as the issue asked: a restart clears the signal and adds exec/restart volume on dockerd (#117). cAdvisor already runs oneContainerInspectper container per 30s housekeeping to get this, so nothing new hits the daemon.Docs: Monitoring.md's "nothing scrapes or alerts on that today" replaced with a pointer to the rule, alert table row,
ContainerUnhealthyadded to the generic rules list in Adding-a-New-Service.md, Services.md cadvisor row.Verification
promtool check rulesin the running prometheus container: 39 rules, SUCCESS./-/reloadloaded the old content (the documented bind-mount gotcha);docker restart prometheuspicked it up.health-probe(alpine:3,--health-cmd false --health-interval 5s --health-retries 1):docker inspectshowedunhealthywithin 12s,container_health_state{name="health-probe"}was0in Prometheus within a minute.starting= 0) and dropped out after its first passing healthcheck, which is the case the 6m exists for.homelab-containers:alertmanager_notifications_total{integration="webhook"}went 3 → 4 with every_failed_totalreason at 0, and ntfy's stats line wentmessages_published=385→386in the same minute.docker rm -f health-probe: inactive in Prometheus at the 03:06:43 evaluation, about 5m after removal. cAdvisor stamps its samples, so Prometheus writes no staleness marker and the series lingers for the 5m lookback (Prometheus docs § Staleness). Added as a Monitoring.md gotcha; a container that turns healthy again resolves on the next evaluation.🤖 Generated with Claude Code