Skip to content

fix(alerts): estate stopped-collector rules also see a frozen .prom file - #1587

Merged
Gerrrt merged 1 commit into
mainfrom
fix/estate-stopped-mtime
Nov 19, 2026
Merged

Gerrrt merged 1 commit into
mainfrom
fix/estate-stopped-mtime

Conversation

@Gerrrt

@Gerrrt Gerrrt commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

What changed

PatchStateStopped and GuestStateStopped in stacks/observability/prometheus/rules/host.rules.yaml each gain a second branch, or'd to the existing absence branch, that fires when the collector's .prom file 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 on guest-state.prom, > 3600. That is six missed runs of the ten-minute timer. It is the window ThinPoolStateStale and GuestDiskStateStale use, and it matches HypervisorGuestStopped's own hour.

On the estate the mtime series carries instance, which Alloy sets from ALLOY_HOSTNAME. That is the same hostname the collectors write into host ($(hostname)). So label_replace copies instance into host and 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 main after it.

Why

Copilot's review of #1585 noted that a stopped timer leaves its .prom file 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's PatchStateStopped already 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 run homelab-patch-state (apt hosts) or homelab-guest-state (Saruman). If the mtime branch is wrong, the worst case is a PatchStateStopped or GuestStateStopped that 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 and InstanceDown speaks.

  • No change to network segmentation or firewall rules
  • No new port published to a VLAN that could not already reach the service
  • No credential added outside secrets/*.sops.yaml

Verification

Run on the Mac (no Docker, no age key):

  • promtool check rules stacks/observability/prometheus/rules/host.rules.yaml: SUCCESS: 62 rules found

  • promtool 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 with host: oracle.
    • PatchStateStopped: file rewritten daily, with an old guest-state.prom on the same instance. Quiet at 79h.
    • GuestStateStopped: series present, file frozen. Quiet at 55m, firing at 95m with host: Saruman.
    • GuestStateStopped: file rewritten every 5m, with an old guest-disk-state.prom beside it. Quiet at 3h.
  • Mutation check, running only these rules' cases against a mutated rule file. Each mutation fails its case:

    • apt mtime branch replaced with vector(0) > 1: FAILED at 2d1h
    • guest mtime branch replaced: FAILED at 1h35m
    • apt regex loosened to .*state\.prom: FAILED at 3d7h. The first version sampled the quiet case hourly, and this mutation survived it, still pending because for restarts in each gap. It is now sampled every 5m, and the case's comment says why.
    • guest regex loosened to .*state\.prom: FAILED at 3h
  • python3 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 a uv tool run --pip-args incompatibility, unrelated to this change; CI runs it.

  • make validate was not run (no Docker here). CI runs the full suite.

  • make validate passes (CI)

  • Deployed to the lab and confirmed working

  • Docs updated (docs/changelog.md)

🤖 Generated with Claude Code

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>
Copilot AI balanced review requested due to automatic review settings November 19, 2026 19:41
@Gerrrt
Gerrrt enabled auto-merge (squash) November 19, 2026 19:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 PatchStateStopped and GuestStateStopped, 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

@Gerrrt
Gerrrt merged commit 1e7aae2 into main Nov 19, 2026
10 checks passed
@Gerrrt
Gerrrt deleted the fix/estate-stopped-mtime branch November 19, 2026 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants