From 934448449b4fa6a6c8e70a248bf1d1349422a5df Mon Sep 17 00:00:00 2001 From: Garrett Allen <98648590+Gerrrt@users.noreply.github.com> Date: Mon, 23 Nov 2026 05:27:59 +0000 Subject: [PATCH 1/2] feat(observability): watch NUT's upsmon logs, so a disarmed shutdown 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 --- README.md | 4 +- docs/changelog.md | 11 ++ docs/observability.md | 14 ++- docs/runbooks/shut-down-on-the-ups.md | 10 ++ docs/security.md | 2 +- stacks/observability/README.md | 2 +- .../observability/loki/rules/nut.rules.yaml | 115 ++++++++++++++++++ stacks/observability/loki/tests/nut.test.yaml | 112 +++++++++++++++++ 8 files changed, 265 insertions(+), 5 deletions(-) create mode 100644 stacks/observability/loki/rules/nut.rules.yaml create mode 100644 stacks/observability/loki/tests/nut.test.yaml diff --git a/README.md b/README.md index 98319e296..616e16c2d 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ documents for different readers. can't run an agent (firewall, switch, UPS, iLO). One agent config, deployed identically everywhere. [How](docs/architecture.md#observability-data-flow) - **Dashboards and alerting as code.** 8 provisioned dashboards, 156 panels, and - 183 alert rules — 161 metric-based in Prometheus, 22 log-based in Loki — sharing + 186 alert rules — 161 metric-based in Prometheus, 25 log-based in Loki — sharing one Alertmanager routing tree. No dashboard exists only in a database. - **Secrets encrypted in-repo with SOPS + age.** Per-device credentials, decrypted at deploy time into gitignored paths, with `git log` showing which @@ -209,7 +209,7 @@ inbound passes may still reach it. Data flow and the maintained Mermaid topology │ ├── observability/ # the estate's stack on prometheus — ten services │ │ ├── prometheus/ # config, file_sd targets, 161 alert rules │ │ ├── alertmanager/ # routing and inhibition -│ │ ├── loki/ # single-binary config + 22 LogQL rules +│ │ ├── loki/ # single-binary config + 25 LogQL rules │ │ ├── alloy/ # the agent config directory, shipped to every host │ │ ├── snmp-exporter/ # generator.yaml is the source of truth │ │ └── grafana/ # provisioning + 8 dashboards diff --git a/docs/changelog.md b/docs/changelog.md index fb94ad9f1..fd9ae5898 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -19,6 +19,17 @@ docstring gives: it is a record, not a claim about now. ## 2026-11-23 +- **NUT is watched from its own logs.** The 2026-11-13 audit of `mjolnir` + found that nothing watched the shutdown path itself, which is how the + driver could stay down until 2026-11-07 with only the generic card-silence + alerts firing. Every `upsmon` but `smaug`'s was already in Loki: `morpheus`'s + through pfSense's syslog, `Saruman`'s and `trinity`'s through the journal. + `loki/rules/nut.rules.yaml` adds `NutDriverNotConnected` and + `NutCommunicationsLost`, both critical, and `NutMonitorFailedToStart`. They + were evaluated against the 48 hours to 2026-11-23 and would not have fired. + The brief *data stale* spells, about a hundred a day, are left alone: their + cause is not established, and they do not line up with the Prometheus + scrape of the card. - **`mjolnir`'s card was silent for eight days, and the UPS shutdown was disarmed for at least two of them.** This records what the 2026-11-13 read-only audit of `mjolnir` found and no entry had written down. diff --git a/docs/observability.md b/docs/observability.md index 193825f30..b557182ed 100644 --- a/docs/observability.md +++ b/docs/observability.md @@ -352,7 +352,7 @@ separates a quiet stream from a stopped one. ## Alerting -183 rules in total: 161 metric-based in `prometheus/rules/`, and 22 log-based in +186 rules in total: 161 metric-based in `prometheus/rules/`, and 25 log-based in `loki/rules/`. ### Log-based (Loki ruler) @@ -373,6 +373,18 @@ series anyway. On the hosts that ship their journal, a failing unit was seen by nothing: `logrotate` failed nightly on `prometheus` and `oracle` from 2026-10-16 until the 2026-11-23 re-audit found it. +`loki/rules/nut.rules.yaml` watches the UPS shutdown path, which the card's +SNMP cannot see. Every `upsmon` but `smaug`'s is already in Loki: `morpheus`'s +through pfSense's syslog, `Saruman`'s and `trinity`'s through the journal. +`NutDriverNotConnected` (critical) fires when an `upsmon` has had "Driver not +connected" ten times in ten minutes, which is the driver on `morpheus` staying +down and the shutdown disarmed, as it was until 2026-11-07. +`NutCommunicationsLost` (critical) fires on upsmon's own "is unavailable", +five minutes without UPS data on that host. `NutMonitorFailedToStart` catches +an `upsmon` that refused its configuration and exited. The brief *data stale* +spells, about a hundred a day and seconds long, are left alone, and so is +silence: an `upsmon` that is not running logs nothing. + **OOM kills have four owners** ([#903](https://github.com/Gerrrt/HomeLab/issues/903), [#1095](https://github.com/Gerrrt/HomeLab/issues/1095)): - `KernelOomKill`: the machine-wide killer, read from the kernel's line. diff --git a/docs/runbooks/shut-down-on-the-ups.md b/docs/runbooks/shut-down-on-the-ups.md index 1fed76d82..49f452def 100644 --- a/docs/runbooks/shut-down-on-the-ups.md +++ b/docs/runbooks/shut-down-on-the-ups.md @@ -1226,6 +1226,16 @@ Then close [#574](https://github.com/Gerrrt/HomeLab/issues/574). ## If something goes wrong +**`NutDriverNotConnected` or `NutCommunicationsLost` paged.** These read +`upsmon`'s own logs in Loki (`loki/rules/nut.rules.yaml`), so they fire +whether or not the card still answers SNMP. Until it clears, **the shutdown +is disarmed** on the host it names. On `morpheus`, run `upsc mjolnir`: if it +says `Driver not connected`, the `snmp-ups` driver is down, so check that the +card answers at `https://10.0.99.10`, then *Services → UPS → Save* restarts +the driver. On a client, it cannot reach `10.0.99.1:3493`: re-run that host's +verify step (3.5, 4.3 or 4b.5). `smaug` ships no logs, so these alerts never +name it. + **`upsc` says `Connection refused`.** Either `upsd` is not listening on that address (check 1.6) or the pass rule is below the block or the catch-all (check 2.5). Both look identical from the client. diff --git a/docs/security.md b/docs/security.md index 3f45e6ba2..38b2c2e98 100644 --- a/docs/security.md +++ b/docs/security.md @@ -33,7 +33,7 @@ What this network is actually built to survive: | A rooted range target reaching `gandalf` itself | **Dropped at `vmbr1`, before the host firewall, once applied.** The host has no address on the range bridge, but Linux answers ARP for its addresses on any interface and accepts a packet for them on any interface. So a target that adds an on-link route to `10.0.30.30` was reaching the host, and only the Proxmox firewall dropped it. Nothing watches that firewall on `gandalf`. A netdev `ingress` table on `vmbr1` now drops every frame the bridge passes up to the host, ARP included, without touching guest-to-guest traffic ([`build-the-playground.md`](runbooks/build-the-playground.md) §2, proved by §8 check four). Behind it, `gandalf` holds no estate credential, no GitHub login, no personal tooling and no third-party apt repository (§4, *Nothing else on `gandalf`*), so the host gives nothing beyond itself. The audits of 2026-11-13 and 2026-11-22 found credentials, then tooling and two third-party repositories. The credentials were gone by 2026-11-22. **The table and the tooling removal are not yet applied** | | Someone on Winterfell or Hicks logging in to `trinity` | **Key-only `sshd` since 2026-11-20; no host firewall by decision.** `trinity` holds the household's data and the sensitive tier's age key, and its `sshd` answers Hicks (by [ADR-0031](adr/0031-narrow-hicks-to-a-named-list-on-winterfell-and-leave-the-lab-open.md)'s list) and every host on VLAN 99, between which pfSense never filters. [`build-the-sensitive-tier-host.md`](runbooks/build-the-sensitive-tier-host.md) §3 now makes `sshd` key-only through a drop-in that outranks cloud-init's, refuses root and X11 forwarding, and keeps `authorized_keys` to `prometheus`'s key and Hicks's. The audit of 2026-11-13 found it taking passwords, with X11 forwarding on and 17 keys imported from GitHub. The step was applied on 2026-11-20: a password-only login is refused with `Permission denied (publickey)`, and three keys remain, `prometheus`'s, Hicks's and the operator's laptop, the last kept by decision. Agent sessions run on `trinity` as the operator, by decision ([ADR-0123](adr/0123-keep-agent-sessions-on-trinity.md)). `ufw` is installed and stays disabled, unlike `phoenix`'s ([ADR-0117](adr/0117-give-phoenix-a-key-only-sshd-and-a-default-deny-inbound-policy.md)): the other two ports `trinity` answers, `443` and `53`, are published by Docker, whose rules run ahead of `ufw`'s, so a policy would govern `22` alone, which the drop-in already closes to anything without a key. Nothing routes through `trinity`, and as the spare firewall a host policy is one more thing to get in the way the day it stands in for `morpheus`. What reaches `443` and `53` is set by pfSense and by the stack's bind addresses | | Someone with the trusted Wi-Fi key quietly joining | Kea's lease log reaches Loki; `UnknownDeviceOnTrustedSegment` fires the first time a MAC appears on VLAN 50 in seven days ([ADR-0019](adr/0019-read-device-joins-from-the-dhcp-server.md)) | -| Losing visibility of a failure | 183 alert rules, 30 days of metrics and logs | +| Losing visibility of a failure | 186 alert rules, 30 days of metrics and logs | | Someone on a reachable VLAN silencing an alert to hide a failure | Alertmanager binds to `127.0.0.1`; silences go through authenticated Grafana | | Mains power loss | **The rack, yes; the monitoring path, yes — on two laptop cells that were measured for the first time on 2026-09-12.** A pack fitted to `mjolnir` on 2026-08-28 passed its self-test; the TP-Link carrying `prometheus` and `oracle` has been on UPS power since 2026-09-08 ([#110](https://github.com/Gerrrt/HomeLab/issues/110)); the laptops ride a cut out on their own batteries, which `HostBatteryHealthLow` in `host.rules.yaml` now reads — `prometheus`'s cell was replaced on 2026-09-18 and reads 101 % of design, `oracle`'s was replaced on 2026-09-29 and reads 100 %, its design figure rather than a learned one ([#531](https://github.com/Gerrrt/HomeLab/issues/531)) — and **each runtime was measured once: `prometheus`'s on 2026-09-19, about 2.5 hours from full at the stack's load, and `oracle`'s on 2026-09-29, about 5.2 hours**; since the same day the projection is recorded on every cut and pages under thirty minutes (`HostBatteryRuntimeLow`, [#532](https://github.com/Gerrrt/HomeLab/issues/532)), but neither pack reports a moving cell temperature, so this row is answered for both hosts' runtime and for neither's cell temperature — see below. **What happens when the cut outlasts the pack is configured and accepted without a live test.** Since 2026-09-23 the firewall's NUT server reads `mjolnir`, and `Saruman` and `smaug` subscribe to it on their own gateway addresses, so a real cut would now try to run the sequence [ADR-0049](adr/0049-shut-down-on-the-ups-from-a-nut-server-on-the-firewall.md) decides: `Saruman` and `smaug` halt first and `morpheus` last. Since the move into the 32U rack on 2026-11-06 the PDU also carries `trinity`, `gandalf` (off until its build) and the console, with `smaug` racked and on the PDU directly rather than by its old long cord to the media room. [ADR-0107](adr/0107-subscribe-trinity-to-the-ups-and-bound-saruman-s-guest-stop.md) makes `trinity` a third subscriber and bounds `Saruman`'s guest stop. `Saruman`'s half was applied on 2026-11-13 (`down=90` on the four ordered guests, and its monitor stays logged in until they are down); `trinity`'s subscription, `HOSTSYNC 600` on `morpheus` and the card's 16-minute threshold followed on 2026-11-20, so all three subscribers would now halt before the pack empties; `gandalf`, the console and `neo` are left to the pack by decision. The pack itself is unmeasured: about 47 minutes at 21 % load is the card's own estimate. Neither the forced-shutdown proof nor a mains pull will be run ([ADR-0121](adr/0121-accept-the-ups-shutdown-without-a-live-test.md)) | | The estate being down while the person who runs it is unavailable | **Documentation, yes; data, no copy outside the house, by decision.** ADR-0011 puts the emergency tier on paper; [ADR-0023](adr/0023-keep-the-household-recovery-path-outside-the-estate.md) extends the same reasoning to the sensitive tier's data. That tier has held real photographs since 2026-09-28. [ADR-0122](adr/0122-drop-the-household-copy.md) dropped their copy outside the estate, so a loss of the house loses them — see below | diff --git a/stacks/observability/README.md b/stacks/observability/README.md index ad059c3ab..172f125cb 100644 --- a/stacks/observability/README.md +++ b/stacks/observability/README.md @@ -61,7 +61,7 @@ alertmanager/ alertmanager.yaml severity + category routing, inhibition loki/ loki-config.yaml single-binary, filesystem, 30-day retention - rules/*.rules.yaml 22 LogQL rules, security and watchdog, evaluated by Loki's ruler + rules/*.rules.yaml 25 LogQL rules, security, watchdog and NUT, evaluated by Loki's ruler alloy/ the agent config — Alloy loads the directory config.alloy every monitored host docker.alloy hosts with a Docker socket diff --git a/stacks/observability/loki/rules/nut.rules.yaml b/stacks/observability/loki/rules/nut.rules.yaml new file mode 100644 index 000000000..d1df7e462 --- /dev/null +++ b/stacks/observability/loki/rules/nut.rules.yaml @@ -0,0 +1,115 @@ +--- +# NUT, the UPS shutdown path, read from its own logs. +# +# WHY THESE EXIST. The UPS card is polled over SNMP and ups.rules.yaml pages on +# what it reports. None of that sees NUT: the driver on morpheus that turns the +# card's low-battery signal into a halt, and the upsmon clients that act on it. +# From about 2026-10-30 to 20:59 on 2026-11-07 the driver was down. morpheus's +# upsmon logged "Driver not connected" 23,048 times from 2026-11-05 alone, a +# mains cut would have halted nothing in order, and the only alerts were the +# generic card-silence ones (the changelog, 2026-11-23). A driver that stays +# down while the card still answers SNMP would raise nothing at all. +# +# WHERE THE LINES COME FROM. Every upsmon is already in Loki: +# +# morpheus pfSense's syslog, through loki.source.syslog "network": +# log_type="syslog", app="upsmon" (and "upsd", "snmp-ups"). +# Saruman the journal, unit="nut-monitor.service". +# trinity the same. +# smaug nothing: TrueNAS ships no logs to Loki. Its upsmon is unwatched. +# +# A union of two branches, the way security.rules.yaml reads sshd: `or` keeps +# each host counted once, from its one source. +# +# WHAT IS DELIBERATELY NOT HERE. +# - The brief "data stale" spells. Measured over 2026-11-16..22: about 100 a +# day from upsd, each lasting 1 to 5 s, and upsmon's "Communications ... +# lost" back within 5 to 10 s. Their cause is not established (they do not +# line up with the Prometheus scrape of the card), and an alert on them +# would fire all day. The two rules below fire only on a loss that lasts. +# - Absence. If upsmon itself stops, it logs nothing; a rule on silence would +# lean on the stale spells above as its heartbeat, and would start firing +# the day they are fixed. +groups: + - name: nut + interval: 1m + rules: + - alert: NutDriverNotConnected + # upsd answers but has no driver behind it, so every upsmon polls and + # gets "Driver not connected". Sustained, the shutdown is disarmed: the + # clients cannot see the card's low-battery signal. + # + # A driver restart is not this. pfSense restarts it on a save and on + # every boot of morpheus, and each restart logs one or two of these + # lines per upsmon (seven restarts in the week to 2026-11-22, none over + # two lines). Ten in ten minutes is a driver that stayed down. + expr: | + ( + sum by (host) (count_over_time({log_type="syslog", app="upsmon"} |= "failed - Driver not connected" [10m])) + or + sum by (host) (count_over_time({unit="nut-monitor.service"} |= "failed - Driver not connected" [10m])) + ) >= 10 + for: 5m + labels: + component: power + severity: critical + category: power + annotations: + runbook_url: "https://github.com/Gerrrt/HomeLab/blob/main/docs/runbooks/shut-down-on-the-ups.md#what-this-does" + summary: "The UPS shutdown is disarmed: NUT on morpheus has no driver for mjolnir" + description: >- + upsmon on {{ $labels.host }} logged "Driver not connected" + {{ $value }} times in ten minutes. The snmp-ups driver on morpheus + is down, so a mains cut would halt nothing in order. Check + Services → UPS on morpheus and `upsc mjolnir` there; the card's + own SNMP may still be answering. + + - alert: NutCommunicationsLost + # upsmon logs "UPS is unavailable" once it has had no data for + # NOCOMMWARNTIME (300 s by default, set nowhere here), and again every + # 300 s while that lasts. One line is therefore five minutes without the + # UPS, on that host: a client that cannot reach morpheus, or morpheus + # that cannot reach the card. Either way that host will not halt on + # the card's signal. + expr: | + ( + sum by (host) (count_over_time({log_type="syslog", app="upsmon"} |= " is unavailable" [10m])) + or + sum by (host) (count_over_time({unit="nut-monitor.service"} |= " is unavailable" [10m])) + ) > 0 + for: 0s + labels: + component: power + severity: critical + category: power + annotations: + runbook_url: "https://github.com/Gerrrt/HomeLab/blob/main/docs/runbooks/shut-down-on-the-ups.md#what-this-does" + summary: "{{ $labels.host }} has had no UPS data for five minutes" + description: >- + upsmon on {{ $labels.host }} reports the UPS unavailable. That host + will not halt on the card's low-battery signal until it is back. If + the host is morpheus, the driver or the card is at fault; if it is + a client, check that it can reach 10.0.99.1 on 3493. + + - alert: NutMonitorFailedToStart + # "Fatal error" is how upsmon refuses its configuration, for example + # MINSUPPLIES above the power values configured, which trinity did five + # times on 2026-11-20 before its upsmon.conf was right. It then exits, + # and an upsmon that is not running logs nothing else. + expr: | + ( + sum by (host) (count_over_time({log_type="syslog", app="upsmon"} |= "Fatal error" [15m])) + or + sum by (host) (count_over_time({unit="nut-monitor.service"} |= "Fatal error" [15m])) + ) > 0 + for: 0s + labels: + component: power + severity: warning + category: power + annotations: + summary: "upsmon on {{ $labels.host }} refused to start" + description: >- + upsmon logged a fatal error on {{ $labels.host }} and exited, so + that host is not subscribed to the UPS. Read + `journalctl -u nut-monitor` there for the line before it. diff --git a/stacks/observability/loki/tests/nut.test.yaml b/stacks/observability/loki/tests/nut.test.yaml new file mode 100644 index 000000000..1037257db --- /dev/null +++ b/stacks/observability/loki/tests/nut.test.yaml @@ -0,0 +1,112 @@ +--- +# Behaviour tests for loki/rules/nut.rules.yaml, run by +# scripts/test_loki_rules.py. The format is security.test.yaml's: each case +# pushes these lines into a throwaway Loki and runs the rule's own expr as an +# instant query; `expect` is the series it must return, [] none. +# +# The lines are upsmon's own, as Loki stores them on 2026-11-22: morpheus's +# arrive through pfSense's syslog with the message only, and the clients' +# through the journal, where the UPS is named mjolnir@10.0.99.1. +tests: + # --- NutDriverNotConnected -------------------------------------------------- + - alert: NutDriverNotConnected + name: a driver down on morpheus, upsmon polling every five seconds, fires + streams: + - labels: {log_type: syslog, app: upsmon, host: morpheus} + entries: + - before: 9m + count: 100 + every: 5s + line: Poll UPS [mjolnir] failed - Driver not connected + expect: + - {host: morpheus} + + - alert: NutDriverNotConnected + name: the same seen from a client's journal fires for that client + streams: + - labels: {log_type: journal, unit: nut-monitor.service, host: trinity} + entries: + - before: 9m + count: 100 + every: 5s + line: Poll UPS [mjolnir@10.0.99.1] failed - Driver not connected + expect: + - {host: trinity} + + - alert: NutDriverNotConnected + name: a driver restart, two lines per upsmon, does not + streams: + - labels: {log_type: syslog, app: upsmon, host: morpheus} + entries: + - before: 3m + count: 2 + every: 3s + line: Poll UPS [mjolnir] failed - Driver not connected + - labels: {log_type: journal, unit: nut-monitor.service, host: trinity} + entries: + - before: 3m + line: Poll UPS [mjolnir@10.0.99.1] failed - Driver not connected + expect: [] + + - alert: NutDriverNotConnected + name: the everyday stale spells do not + streams: + - labels: {log_type: syslog, app: upsmon, host: morpheus} + entries: + - before: 8m + count: 12 + every: 40s + line: Poll UPS [mjolnir] failed - Data stale + expect: [] + + # --- NutCommunicationsLost -------------------------------------------------- + - alert: NutCommunicationsLost + name: five minutes without the UPS on a client fires + streams: + - labels: {log_type: journal, unit: nut-monitor.service, host: Saruman} + entries: + - before: 2m + line: UPS mjolnir@10.0.99.1 is unavailable + expect: + - {host: Saruman} + + - alert: NutCommunicationsLost + name: on morpheus too + streams: + - labels: {log_type: syslog, app: upsmon, host: morpheus} + entries: + - before: 2m + line: UPS mjolnir is unavailable + expect: + - {host: morpheus} + + - alert: NutCommunicationsLost + name: a loss that comes back within seconds does not + streams: + - labels: {log_type: journal, unit: nut-monitor.service, host: Saruman} + entries: + - before: 3m + line: Communications with UPS mjolnir@10.0.99.1 lost + - before: 2m55s + line: Communications with UPS mjolnir@10.0.99.1 established + expect: [] + + # --- NutMonitorFailedToStart ------------------------------------------------ + - alert: NutMonitorFailedToStart + name: trinity's refusal of 2026-11-20 fires + streams: + - labels: {log_type: journal, unit: nut-monitor.service, host: trinity} + entries: + - before: 5m + line: "Fatal error: insufficient power configured!" + expect: + - {host: trinity} + + - alert: NutMonitorFailedToStart + name: a clean start does not + streams: + - labels: {log_type: journal, unit: nut-monitor.service, host: trinity} + entries: + - before: 5m + line: Network UPS Tools upsmon 2.8.4 release + expect: [] From 33aaeabac421e63cf106d9a9c89ae7ed08b34af5 Mon Sep 17 00:00:00 2001 From: Garrett Allen <98648590+Gerrrt@users.noreply.github.com> Date: Mon, 23 Nov 2026 14:32:12 +0000 Subject: [PATCH 2/2] fix(observability): page on a driver that is down now, and split the 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 --- docs/observability.md | 4 +-- docs/runbooks/shut-down-on-the-ups.md | 19 ++++++++---- .../observability/loki/rules/nut.rules.yaml | 17 +++++++---- stacks/observability/loki/tests/nut.test.yaml | 30 ++++++++++++++----- 4 files changed, 49 insertions(+), 21 deletions(-) diff --git a/docs/observability.md b/docs/observability.md index b557182ed..e8c16e4e4 100644 --- a/docs/observability.md +++ b/docs/observability.md @@ -377,8 +377,8 @@ nothing: `logrotate` failed nightly on `prometheus` and `oracle` from SNMP cannot see. Every `upsmon` but `smaug`'s is already in Loki: `morpheus`'s through pfSense's syslog, `Saruman`'s and `trinity`'s through the journal. `NutDriverNotConnected` (critical) fires when an `upsmon` has had "Driver not -connected" ten times in ten minutes, which is the driver on `morpheus` staying -down and the shutdown disarmed, as it was until 2026-11-07. +connected" ten times in three minutes, held for five, which is the driver on +`morpheus` staying down and the shutdown disarmed, as it was until 2026-11-07. `NutCommunicationsLost` (critical) fires on upsmon's own "is unavailable", five minutes without UPS data on that host. `NutMonitorFailedToStart` catches an `upsmon` that refused its configuration and exited. The brief *data stale* diff --git a/docs/runbooks/shut-down-on-the-ups.md b/docs/runbooks/shut-down-on-the-ups.md index 49f452def..857170765 100644 --- a/docs/runbooks/shut-down-on-the-ups.md +++ b/docs/runbooks/shut-down-on-the-ups.md @@ -1229,12 +1229,19 @@ Then close [#574](https://github.com/Gerrrt/HomeLab/issues/574). **`NutDriverNotConnected` or `NutCommunicationsLost` paged.** These read `upsmon`'s own logs in Loki (`loki/rules/nut.rules.yaml`), so they fire whether or not the card still answers SNMP. Until it clears, **the shutdown -is disarmed** on the host it names. On `morpheus`, run `upsc mjolnir`: if it -says `Driver not connected`, the `snmp-ups` driver is down, so check that the -card answers at `https://10.0.99.10`, then *Services → UPS → Save* restarts -the driver. On a client, it cannot reach `10.0.99.1:3493`: re-run that host's -verify step (3.5, 4.3 or 4b.5). `smaug` ships no logs, so these alerts never -name it. +is disarmed** on the host it names. Which one paged says where to look: + +- `NutDriverNotConnected`, from any host, is the driver on `morpheus`. A + client that logs it has reached `upsd`, so its network is fine. On + `morpheus`, run `upsc mjolnir`: if it says `Driver not connected`, the + `snmp-ups` driver is down, so check that the card answers at + `https://10.0.99.10`, then *Services → UPS → Save* restarts the driver. +- `NutCommunicationsLost` on `morpheus` is the driver or the card, as above. + On a client it is that client's path to `upsd` on 3493: `10.0.30.1` from + `Saruman` (3.3), `10.0.99.1` from `trinity` (4b.4). Run `upsc + mjolnir@` there, then re-run its verify step (3.5 or 4b.5). + +`smaug` ships no logs, so these alerts never name it. **`upsc` says `Connection refused`.** Either `upsd` is not listening on that address (check 1.6) or the pass rule is below the block or the catch-all diff --git a/stacks/observability/loki/rules/nut.rules.yaml b/stacks/observability/loki/rules/nut.rules.yaml index d1df7e462..4a3661e9a 100644 --- a/stacks/observability/loki/rules/nut.rules.yaml +++ b/stacks/observability/loki/rules/nut.rules.yaml @@ -42,12 +42,17 @@ groups: # A driver restart is not this. pfSense restarts it on a save and on # every boot of morpheus, and each restart logs one or two of these # lines per upsmon (seven restarts in the week to 2026-11-22, none over - # two lines). Ten in ten minutes is a driver that stayed down. + # two lines). Ten in three minutes is a driver that is down now: upsmon + # polls every 5 s, and morpheus logged one about every 11 s while it was + # down. The window is short so the condition ends within about a minute + # of the driver's return, and `for: 5m` has to see it hold throughout; + # a ten-minute window kept a 50-second outage's lines long enough to + # page five minutes after it was over. expr: | ( - sum by (host) (count_over_time({log_type="syslog", app="upsmon"} |= "failed - Driver not connected" [10m])) + sum by (host) (count_over_time({log_type="syslog", app="upsmon"} |= "failed - Driver not connected" [3m])) or - sum by (host) (count_over_time({unit="nut-monitor.service"} |= "failed - Driver not connected" [10m])) + sum by (host) (count_over_time({unit="nut-monitor.service"} |= "failed - Driver not connected" [3m])) ) >= 10 for: 5m labels: @@ -59,7 +64,8 @@ groups: summary: "The UPS shutdown is disarmed: NUT on morpheus has no driver for mjolnir" description: >- upsmon on {{ $labels.host }} logged "Driver not connected" - {{ $value }} times in ten minutes. The snmp-ups driver on morpheus + {{ $value }} times in three minutes, for five minutes now. The + snmp-ups driver on morpheus is down, so a mains cut would halt nothing in order. Check Services → UPS on morpheus and `upsc mjolnir` there; the card's own SNMP may still be answering. @@ -89,7 +95,8 @@ groups: upsmon on {{ $labels.host }} reports the UPS unavailable. That host will not halt on the card's low-battery signal until it is back. If the host is morpheus, the driver or the card is at fault; if it is - a client, check that it can reach 10.0.99.1 on 3493. + a client, check that it can reach its upsd on 3493: 10.0.30.1 from + Saruman, 10.0.99.1 from trinity. - alert: NutMonitorFailedToStart # "Fatal error" is how upsmon refuses its configuration, for example diff --git a/stacks/observability/loki/tests/nut.test.yaml b/stacks/observability/loki/tests/nut.test.yaml index 1037257db..00fa677be 100644 --- a/stacks/observability/loki/tests/nut.test.yaml +++ b/stacks/observability/loki/tests/nut.test.yaml @@ -6,7 +6,8 @@ # # The lines are upsmon's own, as Loki stores them on 2026-11-22: morpheus's # arrive through pfSense's syslog with the message only, and the clients' -# through the journal, where the UPS is named mjolnir@10.0.99.1. +# through the journal, where the UPS is named by the upsd each one monitors: +# mjolnir@10.0.30.1 on Saruman, mjolnir@10.0.99.1 on trinity. tests: # --- NutDriverNotConnected -------------------------------------------------- - alert: NutDriverNotConnected @@ -14,8 +15,8 @@ tests: streams: - labels: {log_type: syslog, app: upsmon, host: morpheus} entries: - - before: 9m - count: 100 + - before: 3m + count: 36 every: 5s line: Poll UPS [mjolnir] failed - Driver not connected expect: @@ -26,8 +27,8 @@ tests: streams: - labels: {log_type: journal, unit: nut-monitor.service, host: trinity} entries: - - before: 9m - count: 100 + - before: 3m + count: 36 every: 5s line: Poll UPS [mjolnir@10.0.99.1] failed - Driver not connected expect: @@ -48,6 +49,19 @@ tests: line: Poll UPS [mjolnir@10.0.99.1] failed - Driver not connected expect: [] + - alert: NutDriverNotConnected + name: a 55-second outage that has since recovered does not + # Twelve failures, the last over three minutes ago. A ten-minute window + # still counted them, and `for: 5m` then paged after the driver was back. + streams: + - labels: {log_type: syslog, app: upsmon, host: morpheus} + entries: + - before: 4m + count: 12 + every: 5s + line: Poll UPS [mjolnir] failed - Driver not connected + expect: [] + - alert: NutDriverNotConnected name: the everyday stale spells do not streams: @@ -66,7 +80,7 @@ tests: - labels: {log_type: journal, unit: nut-monitor.service, host: Saruman} entries: - before: 2m - line: UPS mjolnir@10.0.99.1 is unavailable + line: UPS mjolnir@10.0.30.1 is unavailable expect: - {host: Saruman} @@ -86,9 +100,9 @@ tests: - labels: {log_type: journal, unit: nut-monitor.service, host: Saruman} entries: - before: 3m - line: Communications with UPS mjolnir@10.0.99.1 lost + line: Communications with UPS mjolnir@10.0.30.1 lost - before: 2m55s - line: Communications with UPS mjolnir@10.0.99.1 established + line: Communications with UPS mjolnir@10.0.30.1 established expect: [] # --- NutMonitorFailedToStart ------------------------------------------------