Repository navigation
feat(observability): watch NUT's upsmon logs, so a disarmed shutdown pages - #1673
Merged
Merged
Conversation
…pages The card's SNMP cannot see NUT. From 10-30 to 11-07 the driver on morpheus was down and only the generic card-silence alerts fired. Every upsmon but smaug's already reaches Loki, so three LogQL rules read them: NutDriverNotConnected and NutCommunicationsLost (critical), and NutMonitorFailedToStart. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
Historical failed polls can satisfy the alert’s five-minute hold after communications recover, causing a false critical page claiming shutdown remains disarmed.
2 open issues
What changed in this PR
Adds log-based monitoring of NUT’s UPS shutdown path, covering failures that card-level SNMP alerts cannot detect.
Changes:
- Adds three Loki alerts for driver disconnection, communications loss, and monitor startup failure.
- Adds behavior fixtures for failures, clean starts, and brief interruptions.
- Documents coverage and troubleshooting, and updates totals to 186 alerts: 161 Prometheus and 25 Loki.
| File | Description |
|---|---|
stacks/observability/README.md |
Updates Loki rule count and coverage. |
stacks/observability/loki/tests/nut.test.yaml |
Adds NUT alert behavior fixtures. |
stacks/observability/loki/rules/nut.rules.yaml |
Adds three NUT log-based alerts. |
README.md |
Updates overall and Loki alert counts. |
docs/security.md |
Updates the alert coverage total. |
docs/runbooks/shut-down-on-the-ups.md |
Adds troubleshooting guidance for NUT pages. |
docs/observability.md |
Describes NUT monitoring and its exclusions. |
docs/changelog.md |
Records the new monitoring and evaluation window. |
Review effort: Balanced
…runbook by alert NutDriverNotConnected counted over ten minutes, so a 50-second outage's lines held the count at ten long enough for `for: 5m` to page after the driver was back. It now counts over three minutes, and a recovered outage is a quiet test case. The runbook sent a client that logged "Driver not connected" to check its network, though that line means it reached upsd. It now splits by alert, and names each client's own upsd: 10.0.30.1 from Saruman, 10.0.99.1 from trinity. The Saruman test lines name 10.0.30.1 to match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gerrrt
added a commit
that referenced
this pull request
Nov 23, 2026
… review points main's #1673 added loki/rules/nut.rules.yaml, which covers a lasting loss (NutCommunicationsLost) and a driver down (NutDriverNotConnected). So NutUpsDataStaleSustained is dropped: it overlapped NutCommunicationsLost and its start-minus-end count across a sliding window could hide an open spell whose predecessor began before the window. NutUpsDataStaleFrequent moves into nut.rules.yaml, at > 24 an hour: the worst sliding hour to 2026-11-23 was 12, not the 9 an hour-aligned count gave. collect-nut-state.sh now finds the status line wherever upsc prints it, so a diagnostic such as "Init SSL without certificate database" before "OL" reads as readable, with two new fixtures. Counts: 192 rules, 166 Prometheus and 26 Loki; the Rules page lists 172. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 of 6 tasks
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
Three Loki rules in a new
stacks/observability/loki/rules/nut.rules.yaml, with behaviour tests inloki/tests/nut.test.yaml:NutDriverNotConnected(critical, category power): anupsmonlogs "Driver not connected" 10 or more times in 10 minutes, for 5 minutes. That means thesnmp-upsdriver onmorpheusstayed down, so the shutdown is disarmed.NutCommunicationsLost(critical):upsmonlogs "… is unavailable", which is its own report of 5 minutes without UPS data on that host.NutMonitorFailedToStart(warning):upsmonlogs "Fatal error" and exits.Each rule reads two sources:
morpheus's syslog (app="upsmon") and the clients' journal (unit="nut-monitor.service", fromSarumanandtrinity). It joins them withor, the waysecurity.rules.yamlreads sshd.observability.md, the shutdown runbook's If something goes wrong, the changelog and the rule counts are updated.Why
The 2026-11-13
mjolniraudit found that nothing watches NUT itself. From about 10-30 to 11-07 the driver onmorpheuswas down. Only the generic card-silence alerts fired, and a driver down while the card still answers SNMP would have raised nothing at all. (The outage is recorded in the changelog by #1656.)Blast radius
Alerting only. If the rules are wrong, they page falsely on the
urgentreceiver or stay quiet. Each one was evaluated against the live Loki at 9 instants across the 48 hours to 2026-11-23, and none would have fired. That window includes seven driver restarts and about 200 stale spells.Not covered:
smaug: it ships no logs to Loki.A stopped
upsmon: it logs nothing, and a rule on silence would depend on the stale flapping as its heartbeat.The flapping itself: about 100 stale spells a day, 1–5 s each, cause not established. Left alone on purpose.
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.yamlVerification
make validate: passed before the rebase.Skipped in that run:
backup-offsite.sh's path refusal (/tmpis a tmpfs; CI covers it), and the unit, installed-timer and sensitive-stack checks that run only from the deployment checkout.After rebasing onto main:
check_docs.pyreads 161 Prometheus + 25 Loki rules../scripts/lint.shpasses everything.test_loki_rules.py: 62/62 tests over 25 of 25 rules.The test cases:
upsmonlines from both sourcesAfter merge: confirm the ruler loads the group (
/loki/api/v1/rules).make validatepassesDeployed to the lab and confirmed working
Docs updated
Merge order: this and #1672 both change the rule counts. Whichever merges second needs a rebase to 164 + 25 = 189.
🤖 Generated with Claude Code