Skip to content

fix(alerts): range-check every SSD wear branch, and warn on repeatedly failing units - #1657

Merged
Gerrrt merged 2 commits into
mainfrom
fix/ssd-wear-range-and-failed-units
Nov 23, 2026
Merged

Gerrrt merged 2 commits into
mainfrom
fix/ssd-wear-range-and-failed-units

Conversation

@Gerrrt

@Gerrrt Gerrrt commented Nov 23, 2026

Copy link
Copy Markdown
Owner

What changed

  • SSD wear: collect-smart-state.sh now drops a life-left value outside 0–100 on all three ATA wear spellings, not just Percent_Lifetime_Remain/SSD_Life_Left. A drive with no valid figure renders no wear series rather than a negative one. NVMe's percentage_used is unchanged.
  • New Loki rule SystemdUnitFailed (warning): it fires when a system unit fails at least twice in 48 hours, read from PID 1's own journal line. homelab-* units are left to ScheduledJobFailed, and oom-kill to UnitOomKilled.
  • Docs: rule counts are now 183 total and 22 Loki, the new rule is described in observability.md, and a 2026-11-23 changelog entry corrects the 2026-11-13 one.

Why

A re-audit of prometheus on 2026-11-23 found two problems:

  • SSD wear. The fix from the earlier PR, fix(alerts): hold trinity's age recipients to a deadline, and stop negative SSD wear #1488, was deployed, but the Apple SSD SM256E still rendered homelab_smart_percentage_used = -78 on 2026-11-22. The value comes from one of the normalised-column branches, which weren't range-checked.
  • Failing units. logrotate has failed every night since 2026-10-16 on prometheus and on oracle, because cloud-init and cloud-init-base both ship a rotation for the same log. Nothing saw it. Only heimdall exports node_systemd_unit_state, and no rule reads that series. Turning that collector on in Alloy would mean mounting the system D-Bus socket into every Alloy container.

Blast radius

Once this deploys, SystemdUnitFailed fires on prometheus and oracle for logrotate.service. That is intended; fixing the duplicate config on each host clears it. Over the previous 14 days, only units that failed repeatedly would have fired: logrotate on both hosts, nut-monitor on trinity, suricata on oracle. The single failures during shutdowns would not.

The Apple SSD's wear series disappears until someone reads smartctl -A with root and the real attribute is mapped. No rule needs the series to exist.

What this rule misses: a service that fails once and stays down.

  • 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

  • Live check: the new rule's expression, run against the live Loki, returned exactly {host="oracle", failed_unit="logrotate.service"} and {host="prometheus", failed_unit="logrotate.service"}.

  • test_loki_rules.py: 53/53 tests over 22/22 rules pass, including three new cases:

    • two failures fire;
    • one failure, as at a shutdown, does not;
    • scheduled jobs, OOM kills, logger lines and user units do not.

    The cases are kept apart by unit name, because three 48-hour windows would go past the 150 hours of history Loki accepts.

  • collect-smart-state.sh --self-test: all checks pass, including a normalised 178 on each spelling, which renders no series.

  • check_docs.py: OK, 161 Prometheus and 22 Loki rules.

  • Lint: passed, nothing skipped.

  • make validate: still running locally when this was pushed (it was pulling the other stacks' images). CI runs the full suite.

  • make validate passes (CI; the local run had not finished at push)

  • Deployed to the lab and confirmed working (converge applies it on prometheus)

  • Docs updated (docs/, service README, or docs/roadmap.md)

🤖 Generated with Claude Code

…y failing units

The 2026-11-13 SSD fix guarded only Percent_Lifetime_Remain/SSD_Life_Left;
prometheus's Apple SM256E still rendered -78 % used on 2026-11-22, so its
figure comes from a normalised-column branch. All three ATA wear spellings
now drop a life-left outside 0-100.

SystemdUnitFailed (Loki): a system unit failing twice in 48h, read from
PID 1's journal line. logrotate had failed nightly on prometheus and oracle
since 2026-10-16 with nothing watching. homelab-* units stay with
ScheduledJobFailed and oom-kill with UnitOomKilled. Counts and docs updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 23, 2026 05:12
@Gerrrt
Gerrrt enabled auto-merge (squash) November 23, 2026 05:13

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 reported for the ATA wear-reading validation and repeated systemd-failure alert changes.

No open issues 🎉

What changed in this PR

This PR improves observability by rejecting invalid ATA SSD wear readings and adding a warning for repeatedly failing systemd units.

Changes:

  • Range-checks the remaining ATA life-left branches and adds regression fixtures; NVMe handling stays unchanged.
  • Adds SystemdUnitFailed for two failures within 48 hours, excluding scheduled HomeLab jobs and OOM kills covered by other rules.
  • Updates documentation to 183 total alerts, including 22 Loki rules, and records the correction to the earlier SSD fix.
File Description
stacks/​observability/​README.md Updates the Loki rule count.
stacks/​observability/​loki/​tests/​security.test.yaml Tests repeated failures, single failures, and exclusions.
stacks/​observability/​loki/​rules/​security.rules.yaml Adds the repeated systemd failure warning.
scripts/​collect-smart-state.sh Guards remaining ATA wear branches and adds regression fixtures.
README.md Updates total and Loki alert counts.
docs/​security.md Updates the alert coverage count.
docs/​observability.md Documents the new rule and updates counts.
docs/​changelog.md Records the SSD correction and new alert.

Review effort: Balanced

…d-failed-units

# Conflicts:
#	docs/changelog.md
@Gerrrt
Gerrrt merged commit 18a4c52 into main Nov 23, 2026
9 checks passed
@Gerrrt
Gerrrt deleted the fix/ssd-wear-range-and-failed-units branch November 23, 2026 06:04
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