Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 13 additions & 1 deletion docs/observability.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 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*
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.
Expand Down
17 changes: 17 additions & 0 deletions docs/runbooks/shut-down-on-the-ups.md
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,23 @@ 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. 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@<that address>` 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
(check 2.5). Both look identical from the client.
Expand Down
2 changes: 1 addition & 1 deletion docs/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
2 changes: 1 addition & 1 deletion stacks/observability/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
122 changes: 122 additions & 0 deletions stacks/observability/loki/rules/nut.rules.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
---
# 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 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" [3m]))
or
sum by (host) (count_over_time({unit="nut-monitor.service"} |= "failed - Driver not connected" [3m]))
) >= 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 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.

- alert: NutCommunicationsLost
# upsmon logs "UPS <name> 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 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
# 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.
Loading