Repository navigation
fix(alerts): range-check every SSD wear branch, and warn on repeatedly failing units - #1657
Merged
Merged
Conversation
…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>
There was a problem hiding this comment.
🟢 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
SystemdUnitFailedfor 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
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
collect-smart-state.shnow drops a life-left value outside 0–100 on all three ATA wear spellings, not justPercent_Lifetime_Remain/SSD_Life_Left. A drive with no valid figure renders no wear series rather than a negative one. NVMe'spercentage_usedis unchanged.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 toScheduledJobFailed, andoom-killtoUnitOomKilled.observability.md, and a 2026-11-23 changelog entry corrects the 2026-11-13 one.Why
A re-audit of
prometheuson 2026-11-23 found two problems:homelab_smart_percentage_used = -78on 2026-11-22. The value comes from one of the normalised-column branches, which weren't range-checked.logrotatehas failed every night since 2026-10-16 onprometheusand onoracle, becausecloud-initandcloud-init-baseboth ship a rotation for the same log. Nothing saw it. Onlyheimdallexportsnode_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,
SystemdUnitFailedfires onprometheusandoracleforlogrotate.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-monitoron trinity,suricataon oracle. The single failures during shutdowns would not.The Apple SSD's wear series disappears until someone reads
smartctl -Awith 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.
secrets/*.sops.yamlVerification
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:loggerlines 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 validatepasses (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, ordocs/roadmap.md)🤖 Generated with Claude Code