Repository navigation
fix(alerts): estate stopped-collector rules also see a frozen .prom file - #1587
Merged
Merged
Conversation
PatchStateStopped and GuestStateStopped fired only when their series vanished. A collector whose timer stops leaves its .prom in the textfile directory and node_exporter re-serves it, so the series stays present and neither rule saw it. Each gains a second branch on node_textfile_mtime_seconds, as the lab's PatchStateStopped has (#1544): apt-patch-state.prom older than two days, guest-state.prom older than an hour, with label_replace copying `instance` into `host`. Promtool cases fire with the file frozen and stay quiet with it rewritten beside an old file of another collector; removing either branch or loosening either regex to `.*state\.prom` fails them. Refs #1585. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the changes extending stopped-collector alerts to detect frozen files.
No open issues 🎉
What changed in this PR
Extends the estate’s stopped-collector alerts to detect frozen .prom files that remain readable but no longer receive updates, closing the gap left by absence-only checks.
Changes:
- Adds file-age checks to
PatchStateStoppedandGuestStateStopped, using two-day and one-hour thresholds while preserving existing absence checks. - Adds tests for frozen files, regularly rewritten files, and unrelated stale files.
- Updates alert descriptions and records the change in the changelog; the rule count remains unchanged.
| File | Description |
|---|---|
stacks/observability/prometheus/tests/host.test.yaml |
Adds frozen-file and healthy-rewrite cases and updates expected alert descriptions. |
stacks/observability/prometheus/rules/host.rules.yaml |
Adds file-age branches to both alerts and maps instance to host for consistent labels. |
docs/changelog.md |
Records the detection gap, new checks, and regression coverage. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
PatchStateStoppedandGuestStateStoppedinstacks/observability/prometheus/rules/host.rules.yamleach gain a second branch,or'd to the existing absence branch, that fires when the collector's.promfile stops being rewritten:PatchStateStopped:time() - node_textfile_mtime_seconds{file=~".*apt-patch-state\\.prom"} > 2 * 86400. That is two days against the daily 08:00 timer, the lab copy's window from feat(lab): alert on the guests' patch state, and record odin's journal gap #1544.GuestStateStopped: the same onguest-state.prom,> 3600. That is six missed runs of the ten-minute timer. It is the windowThinPoolStateStaleandGuestDiskStateStaleuse, and it matchesHypervisorGuestStopped's own hour.On the estate the mtime series carries
instance, which Alloy sets fromALLOY_HOSTNAME. That is the same hostname the collectors write intohost($(hostname)). Solabel_replacecopiesinstanceintohostand both branches alert under one label set. The comments and descriptions now say what each branch covers, replacing the "WHAT THIS DOES NOT SEE" note. There is a changelog entry, and the rule count is unchanged at 62 in this file.Follows #1585, which merged first; this branch is cut from
mainafter it.Why
Copilot's review of #1585 noted that a stopped timer leaves its
.promfile in the textfile directory. node_exporter then re-serves the last values on every scrape, so the series never goes absent and both rules stay green: the healthiest-looking silence, which these rules exist to catch. The lab'sPatchStateStoppedalready had this branch; the estate's two did not.Refs #1585.
Blast radius
Two warning-level alerts on the estate Prometheus (on
prometheus), for hosts that runhomelab-patch-state(apt hosts) orhomelab-guest-state(Saruman). If the mtime branch is wrong, the worst case is aPatchStateStoppedorGuestStateStoppedthat fires for a host whose collector is in fact running. Its description names the timer and the journal to check. A host that is down loses its mtime series with everything else, so this branch stays quiet andInstanceDownspeaks.secrets/*.sops.yamlVerification
Run on the Mac (no Docker, no age key):
promtool check rules stacks/observability/prometheus/rules/host.rules.yaml:SUCCESS: 62 rules foundpromtool test rules tests/host.test.yaml:SUCCESS. The new cases:PatchStateStopped: series present, file written at t=0 and never again. Quiet at 47h, firing at 49h withhost: oracle.PatchStateStopped: file rewritten daily, with an oldguest-state.promon the same instance. Quiet at 79h.GuestStateStopped: series present, file frozen. Quiet at 55m, firing at 95m withhost: Saruman.GuestStateStopped: file rewritten every 5m, with an oldguest-disk-state.prombeside it. Quiet at 3h.Mutation check, running only these rules' cases against a mutated rule file. Each mutation fails its case:
vector(0) > 1: FAILED at 2d1h.*state\.prom: FAILED at 3d7h. The first version sampled the quiet case hourly, and this mutation survived it, still pending becauseforrestarts in each gap. It is now sampled every 5m, and the case's comment says why..*state\.prom: FAILED at 3hpython3 scripts/check_docs.py:docs OK — 164 Prometheus + 21 Loki rules, …./scripts/lint.sh: actionlint and the local checks PASS. zizmor, packer, tofu and editorconfig-checker were SKIPPED (no Docker daemon). ansible-lint FAILED locally on auv tool run--pip-argsincompatibility, unrelated to this change; CI runs it.make validatewas not run (no Docker here). CI runs the full suite.make validatepasses (CI)Deployed to the lab and confirmed working
Docs updated (
docs/changelog.md)🤖 Generated with Claude Code