From 6ba42b14c2331de8431be07c92374383b07be2e2 Mon Sep 17 00:00:00 2001 From: Gerrrt Date: Tue, 24 Nov 2026 13:06:26 -0800 Subject: [PATCH 1/2] feat(alerts): warn on heimdall's updates, units, heat and silence, and keep its bootloader current MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A read-only re-check of heimdall on 2026-11-24 found its bootloader still at June 2025's: rpi-eeprom-update.service runs with -s, which writes only below Raspberry Pi's critical floor. build-heimdall.md §2 now drops the -s with a drop-in, purges rpi-connect-lite, autoremoves, and has unattended-upgrades remove unused dependencies. It also found nothing reading what heimdall exports. Four warnings on role="display" now do: DisplayUpdatesStalled, DisplayUnitFailed, DisplayHot and DisplayDown, each with a firing and a quiet test. Co-Authored-By: Claude Opus 5.5 --- README.md | 4 +- docs/changelog.md | 30 ++++ docs/observability.md | 17 ++- docs/runbooks/build-heimdall.md | 53 ++++++- docs/runbooks/deploy-stack.md | 2 +- docs/security.md | 2 +- stacks/observability/README.md | 2 +- .../prometheus/rules/host.rules.yaml | 91 ++++++++++++ .../prometheus/targets/node.yaml | 7 +- .../prometheus/tests/host.test.yaml | 138 +++++++++++++++++- 10 files changed, 325 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index ecd19e18c..6f2ee1b11 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 - 210 alert rules — 182 metric-based in Prometheus, 28 log-based in Loki — sharing + 214 alert rules — 186 metric-based in Prometheus, 28 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 @@ -207,7 +207,7 @@ inbound passes may still reach it. Data flow and the maintained Mermaid topology . ├── stacks/ │ ├── observability/ # the estate's stack on prometheus — ten services -│ │ ├── prometheus/ # config, file_sd targets, 182 alert rules +│ │ ├── prometheus/ # config, file_sd targets, 186 alert rules │ │ ├── alertmanager/ # routing and inhibition │ │ ├── loki/ # single-binary config + 28 LogQL rules │ │ ├── alloy/ # the agent config directory, shipped to every host diff --git a/docs/changelog.md b/docs/changelog.md index 84e12cad9..27ba31665 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -19,6 +19,36 @@ docstring gives: it is a record, not a claim about now. ## 2026-11-24 +- **A re-check of `heimdall` found its bootloader never updates, and nothing + watching it.** It was read-only, from the Mac on Hicks, after the + 2026-11-23 audit's fixes. All twelve findings held on the Pi: only 22 and + 9100 listened, sudo asked for the password, the seed files were gone, + Chromium ran under `lwrespawn`, and the journal kept four boots, each with + its cause. Two things a new audit would still find: + - **The bootloader stayed at June 2025.** The `rpi-eeprom` package went + to 28.38 unattended at 06:09, carrying October 2026's bootloader. + `rpi-eeprom-update.service` runs with `-s` at boot, and writes only when + the chip is older than Raspberry Pi's floor for critical fixes. The 09:10 + boot logged "Skipping automatic bootloader upgrade". `build-heimdall.md` + §2 said the nightly reboot made upgraded firmware run, which was true of + the boot partition's firmware and not of the bootloader. + `build-heimdall.md` §2 now drops the `-s` with a drop-in, so each boot + writes the newest default release. + - **No rule read what `heimdall` exports.** `InstanceDown` leaves it out + by design, and the nightly `HostRebooted` is `info`, which is never sent. + `apt_upgrades_pending`, `node_systemd_unit_state` and the SoC's + temperature reached Prometheus and stopped there. Four warnings now read + them, selected by `role="display"`: `DisplayUpdatesStalled`, + `DisplayUnitFailed`, `DisplayHot` and `DisplayDown`. None pages. The + `node.yaml` comment that the scrape was for the throttle state is + corrected: `node_exporter` does not report it. + - **What the VNC purge left.** Five libraries were autoremovable, and + `rpi-connect-lite` was removed but not purged. §2 now purges it, runs + `apt autoremove --purge`, and sets unattended-upgrades to remove unused + dependencies from then on. + - The new §2 steps need the operator's password at the Pi, so they are + written here and not yet applied. + - **The audit of `morpheus` of 2026-11-13 is closed.** This completes the entry "`morpheus` audited, read-only, on 2026-11-13, and re-read on 2026-11-23". A re-check on 2026-11-24 found every finding fixed on the box, diff --git a/docs/observability.md b/docs/observability.md index 7d8937eb2..5c220f98d 100644 --- a/docs/observability.md +++ b/docs/observability.md @@ -352,7 +352,7 @@ separates a quiet stream from a stopped one. ## Alerting -210 rules in total: 182 metric-based in `prometheus/rules/`, and 28 log-based in +214 rules in total: 186 metric-based in `prometheus/rules/`, and 28 log-based in `loki/rules/`. ### Log-based (Loki ruler) @@ -376,10 +376,11 @@ below, for any result but `oom-kill`, from PID 1's own stream. It fires when a system unit fails at least twice in 48 hours. A single failure is not enough, because most single failures are shutdown noise, which a log rule cannot tell apart. `homelab-*` units are left to `ScheduledJobFailed`. It exists because -only `heimdall` exports `node_systemd_unit_state`, and nothing alerts on that -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. +only `heimdall` exports `node_systemd_unit_state`, and `heimdall` ships no +journal, so its failed units are `DisplayUnitFailed`'s, in Prometheus. 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 @@ -550,11 +551,11 @@ argument and for what to do when it exits 1. ### Metric-based (Prometheus) -182 rules across 13 files in `prometheus/rules/`: +186 rules across 13 files in `prometheus/rules/`: | File | Covers | | --- | --- | -| `host.rules.yaml` | Instance down, predictive disk fill, memory, load, clock skew and a clock with no time source at all — `HostClockUnsynchronised` reads `node_timex_sync_status`, because the offset reads zero once timesyncd has restored a clock that is wrong but stable, which is how a cleared RTC wrote fourteen minutes of samples three hours in the past and nothing noticed ([#519](https://github.com/Gerrrt/HomeLab/issues/519)) — reboots, and, for the two laptops, whether the shelf is on mains, whether the cell that carries them through a cut is still worth relying on ([#454](https://github.com/Gerrrt/HomeLab/issues/454), and [`runbooks/replace-the-laptop-cell.md`](runbooks/replace-the-laptop-cell.md) for the swap), how hot that cell is, whether its temperature is being measured at all — on 2026-09-19 it was not, on either host — and how many minutes the host has left once the cut arrives ([#532](https://github.com/Gerrrt/HomeLab/issues/532)); whether the wiki's drift check on `oracle` is still running, and still able to read its claims ([#470](https://github.com/Gerrrt/HomeLab/issues/470), [#1531](https://github.com/Gerrrt/HomeLab/issues/1531)); and, for the NAS, whether every ZFS pool is online — `ZpoolNotOnline` reads `node_zfs_zpool_state`, added after `erebor` lost a disk on 2026-09-19 with the exporter hung ahead of it and `InstanceDown` the only page ([#558](https://github.com/Gerrrt/HomeLab/issues/558), [`runbooks/replace-the-nas-disk.md`](runbooks/replace-the-nas-disk.md)); and whether any drive's unsafe-shutdown count has grown in a day — `SmartDriveUnsafeShutdownsGrowing`, whose page says when `smaug` recorded a clean power-off the same day, because mains removed after a clean shutdown ticks the S3520 and a clean shutdown alone does not ([#746](https://github.com/Gerrrt/HomeLab/issues/746)), the measure of a cut the shutdown sequence [ADR-0049](adr/0049-shut-down-on-the-ups-from-a-nut-server-on-the-firewall.md) decides did not catch, the rule [ADR-0047](adr/0047-collect-smaug-smart-through-a-root-cron-and-the-textfile-collector.md) left to that issue when it carried `smaug`'s counter under the scrape ([#574](https://github.com/Gerrrt/HomeLab/issues/574)); and, for `Saruman`, how full its LVM-thin pools are — which `node_filesystem_*` cannot see — and whether its Proxmox firewall is still on with an inbound policy that drops, from two agent collectors ([#538](https://github.com/Gerrrt/HomeLab/issues/538), [#576](https://github.com/Gerrrt/HomeLab/issues/576)); and whether the `tc` mirror that feeds Zeek on `fenrir` is still delivering packets from every port of the lab bridge — `ZeekMirrorInactive`, Zeek's absence detection answered on the hypervisor because the lab's Loki has no ruler ([#437](https://github.com/Gerrrt/HomeLab/issues/437), [ADR-0068](adr/0068-mirror-the-lab-bridge-to-zeek-with-tc-not-open-vswitch.md)); and whether a guest the hypervisor tags `disposable` has outlived the fortnight it was built for — `DisposableGuestOutlived`, read from each guest's own `qm config` rather than from any list of which guests should exist, which is also why `HypervisorGuestStopped` stays quiet for such a guest, with `GuestConfigUnreadable` covering the read itself failing ([#438](https://github.com/Gerrrt/HomeLab/issues/438), [ADR-0071](adr/0071-run-disposable-investigations-on-a-guest-that-is-destroyed.md)); and a guest tagged `backup` that no enabled backup job selects, as `GuestNotInBackupJob`, after the domain's six fell out of `golem-nightly` through purged tofu destroys (2026-10-10); and how many days the four management consoles' certificates have left — the pfSense GUI, the iLO, `Saruman`'s `:8006` and the TrueNAS UI, none of which the blackbox exporter can reach — `ManagementCertificateExpiringSoon` at 30 days and `ManagementCertificateExpiryImminent` at 7, read from a handshake made inside each console's own segment, with `ManagementCertificateUnchecked` for a console that would not answer and `CertExpiryStateStale` for a collector that stopped ([#857](https://github.com/Gerrrt/HomeLab/issues/857), [ADR-0084](adr/0084-read-management-certificate-expiry-from-inside-each-segment.md)) | +| `host.rules.yaml` | Instance down, predictive disk fill, memory, load, clock skew and a clock with no time source at all — `HostClockUnsynchronised` reads `node_timex_sync_status`, because the offset reads zero once timesyncd has restored a clock that is wrong but stable, which is how a cleared RTC wrote fourteen minutes of samples three hours in the past and nothing noticed ([#519](https://github.com/Gerrrt/HomeLab/issues/519)) — reboots, and, for the two laptops, whether the shelf is on mains, whether the cell that carries them through a cut is still worth relying on ([#454](https://github.com/Gerrrt/HomeLab/issues/454), and [`runbooks/replace-the-laptop-cell.md`](runbooks/replace-the-laptop-cell.md) for the swap), how hot that cell is, whether its temperature is being measured at all — on 2026-09-19 it was not, on either host — and how many minutes the host has left once the cut arrives ([#532](https://github.com/Gerrrt/HomeLab/issues/532)); whether the wiki's drift check on `oracle` is still running, and still able to read its claims ([#470](https://github.com/Gerrrt/HomeLab/issues/470), [#1531](https://github.com/Gerrrt/HomeLab/issues/1531)); and, for the NAS, whether every ZFS pool is online — `ZpoolNotOnline` reads `node_zfs_zpool_state`, added after `erebor` lost a disk on 2026-09-19 with the exporter hung ahead of it and `InstanceDown` the only page ([#558](https://github.com/Gerrrt/HomeLab/issues/558), [`runbooks/replace-the-nas-disk.md`](runbooks/replace-the-nas-disk.md)); and whether any drive's unsafe-shutdown count has grown in a day — `SmartDriveUnsafeShutdownsGrowing`, whose page says when `smaug` recorded a clean power-off the same day, because mains removed after a clean shutdown ticks the S3520 and a clean shutdown alone does not ([#746](https://github.com/Gerrrt/HomeLab/issues/746)), the measure of a cut the shutdown sequence [ADR-0049](adr/0049-shut-down-on-the-ups-from-a-nut-server-on-the-firewall.md) decides did not catch, the rule [ADR-0047](adr/0047-collect-smaug-smart-through-a-root-cron-and-the-textfile-collector.md) left to that issue when it carried `smaug`'s counter under the scrape ([#574](https://github.com/Gerrrt/HomeLab/issues/574)); and, for `Saruman`, how full its LVM-thin pools are — which `node_filesystem_*` cannot see — and whether its Proxmox firewall is still on with an inbound policy that drops, from two agent collectors ([#538](https://github.com/Gerrrt/HomeLab/issues/538), [#576](https://github.com/Gerrrt/HomeLab/issues/576)); and whether the `tc` mirror that feeds Zeek on `fenrir` is still delivering packets from every port of the lab bridge — `ZeekMirrorInactive`, Zeek's absence detection answered on the hypervisor because the lab's Loki has no ruler ([#437](https://github.com/Gerrrt/HomeLab/issues/437), [ADR-0068](adr/0068-mirror-the-lab-bridge-to-zeek-with-tc-not-open-vswitch.md)); and whether a guest the hypervisor tags `disposable` has outlived the fortnight it was built for — `DisposableGuestOutlived`, read from each guest's own `qm config` rather than from any list of which guests should exist, which is also why `HypervisorGuestStopped` stays quiet for such a guest, with `GuestConfigUnreadable` covering the read itself failing ([#438](https://github.com/Gerrrt/HomeLab/issues/438), [ADR-0071](adr/0071-run-disposable-investigations-on-a-guest-that-is-destroyed.md)); and a guest tagged `backup` that no enabled backup job selects, as `GuestNotInBackupJob`, after the domain's six fell out of `golem-nightly` through purged tofu destroys (2026-10-10); and how many days the four management consoles' certificates have left — the pfSense GUI, the iLO, `Saruman`'s `:8006` and the TrueNAS UI, none of which the blackbox exporter can reach — `ManagementCertificateExpiringSoon` at 30 days and `ManagementCertificateExpiryImminent` at 7, read from a handshake made inside each console's own segment, with `ManagementCertificateUnchecked` for a console that would not answer and `CertExpiryStateStale` for a collector that stopped ([#857](https://github.com/Gerrrt/HomeLab/issues/857), [ADR-0084](adr/0084-read-management-certificate-expiry-from-inside-each-segment.md)); and, for the office wall display, which its `role: display` keeps out of `InstanceDown`, four warnings that never page: upgrades from one origin pending for three days, a failed unit, the SoC above 75 °C, and two hours unscraped (`DisplayUpdatesStalled`, `DisplayUnitFailed`, `DisplayHot`, `DisplayDown`, [ADR-0119](adr/0119-put-the-office-wall-dashboard-on-a-pi-5-on-hicks.md)) | | `network.rules.yaml` | SNMP reachability, pf not running, state table, switch links, a switch port whose VLAN changed (`SwitchPortVlanChanged`, from `dot1qPvid`, [#1387](https://github.com/Gerrrt/HomeLab/issues/1387)), iLO hardware and Smart Array cache. `shiva`'s Smart Storage Battery read failed from 2026-08-18 until it was replaced on 2026-09-02, with the array in write-through as a result, so stored metrics before that date show the failed pack — `IloBatteryCondition` names the spare part to order, and the controller rollups are deliberately read at *failed* rather than *degraded* ([#76](https://github.com/Gerrrt/HomeLab/issues/76)). Also whether the remote path's dynamic DNS name still resolves to the WAN address — `DdnsRecordStale` and `DdnsRecordUnchecked`, from the comparison `scripts/collect-gateway-state.sh` makes on the firewall every fifteen minutes ([#604](https://github.com/Gerrrt/HomeLab/issues/604), [ADR-0044](adr/0044-answer-the-endpoint-with-dynamic-dns-from-morpheus.md)); see *What the dynamic DNS series disclose* below | | `ups.rules.yaml` | On battery, low battery, runtime, load, temperature, and whether the shutdown order has time to run: `UpsLowBatteryDurationShort` when the card's low-battery duration is under the 16 minutes [ADR-0107](adr/0107-subscribe-trinity-to-the-ups-and-bound-saruman-s-guest-stop.md) needs, `UpsRideThroughShort` when a charged pack on mains would start the halt under 15 minutes into a cut. Five rules read the AP9335T rack-ambient probe on the card: `UpsTemperatureProbeMissing`, `UpsTemperatureProbeCommsLost`, `RackAmbientTemperatureAlarm` on the card's own limits, and the fixed ones, `RackAmbientTemperatureHigh` over 30 °C and `RackAmbientTemperatureCritical` over 35 °C. The card reports whole degrees, not the tenths PowerNet-MIB describes. A pack was fitted on 2026-08-28 and passed its self-test, so these read real hardware; stored metrics older than that date are the card's fabricated values — see [`runbooks/fit-the-ups-battery.md`](runbooks/fit-the-ups-battery.md) | | `containers.rules.yaml` | Restart loops, OOM kills, memory, throttling | @@ -587,7 +588,7 @@ as loaded and healthy and could not fire for any input ([#63](https://github.com `prometheus/tests/*.test.yaml` holds `promtool test rules` unit tests, which feed a rule synthetic series and assert it fires — paired with a case asserting it stays quiet, because a test that only ever expects silence would have passed -against the broken rule too. Coverage is 182 rules of 182 so far ([#843](https://github.com/Gerrrt/HomeLab/issues/843)) — all twelve +against the broken rule too. Coverage is 186 rules of 186 so far ([#843](https://github.com/Gerrrt/HomeLab/issues/843)) — all twelve in `blackbox.rules.yaml`, all three in `dns.rules.yaml`, all seven in `range.rules.yaml`, `GatewayFilesystemCritical`, `ContainerHighMemory`, `ContainerNearMemoryLimit`, `ContainerRestartLoop`, `ContainerCpuThrottled`, the three container-state rules from diff --git a/docs/runbooks/build-heimdall.md b/docs/runbooks/build-heimdall.md index 47a60ed4b..536194a19 100644 --- a/docs/runbooks/build-heimdall.md +++ b/docs/runbooks/build-heimdall.md @@ -126,14 +126,22 @@ systemctl --failed --no-legend # nothing `unattended-upgrades` installs Debian's updates daily, but its default origins are Debian's alone. Chromium, the kernel, the firmware and the EEPROM come from `archive.raspberrypi.com`, and Raspberry Pi's Chromium -outranks Debian's by its epoch. So none of them update without this: +outranks Debian's by its epoch. So none of them update without this. +The second line removes what an upgrade leaves unused, so old dependencies +do not pile up on a Pi nobody logs in to: ```bash -echo 'Unattended-Upgrade::Origins-Pattern:: "origin=Raspberry Pi Foundation,codename=${distro_codename}";' \ +printf '%s\n' \ + 'Unattended-Upgrade::Origins-Pattern:: "origin=Raspberry Pi Foundation,codename=${distro_codename}";' \ + 'Unattended-Upgrade::Remove-Unused-Dependencies "true";' \ | sudo tee /etc/apt/apt.conf.d/52heimdall-unattended-upgrades apt-config dump | grep -c 'origin=Raspberry Pi Foundation' # 1 +apt-config dump | grep 'Remove-Unused-Dependencies' # "true" ``` +The EEPROM *package* updates this way. The bootloader it carries does not +reach the chip by itself: see the next section. + An upgraded Chromium runs only once Chromium restarts, and a new kernel only once the Pi does. Nothing on the Pi does either by itself, and a Chromium upgrade leaves no reboot-required flag. So the Pi reboots every night. At @@ -161,6 +169,34 @@ sudo systemctl enable --now nightly-reboot.timer systemctl list-timers nightly-reboot.timer --no-legend # next at 04:30 ``` +### The bootloader updates too + +`rpi-eeprom-update.service` runs at every boot with `-s`, which writes a new +bootloader only when the one on the chip is older than a floor Raspberry Pi +sets for critical fixes. Anything newer than that floor stays as it is. On +2026-11-24 the chip held June 2025's bootloader, the package carried October +2026's, and the first boot after the upgrade logged "Skipping automatic +bootloader upgrade". Drop the `-s`, so each boot writes the newest default release when +it is newer than the chip's: + +```bash +sudo mkdir -p /etc/systemd/system/rpi-eeprom-update.service.d +printf '[Service]\nExecStart=\nExecStart=/usr/bin/rpi-eeprom-update -a\n' \ + | sudo tee /etc/systemd/system/rpi-eeprom-update.service.d/50-always.conf +sudo systemctl daemon-reload +sudo systemctl restart rpi-eeprom-update.service # writes it now +sudo reboot +# after the reboot: +rpi-eeprom-update | grep -E '^BOOTLOADER|CURRENT' # up to date +``` + +On a Pi 5 the service writes the chip with `flashrom` while the Pi runs, and +the new bootloader runs from the next boot. The script verifies what it +wrote. If the write fails, it leaves the update and `recovery.bin` on the +boot partition, and the next boot writes the chip from the card instead. +With the nightly reboot, a release that the package brings in at 06:00 is +written at the next 04:30 boot and runs from the one after. + ### A journal that survives a reboot Raspberry Pi OS keeps the journal in memory, to spare the card @@ -191,7 +227,8 @@ packages: sudo systemctl mask --now rpcbind.service rpcbind.socket nfs-blkmap.service \ avahi-daemon.service avahi-daemon.socket \ cups.service cups.socket cups.path bluetooth.service -sudo apt purge -y realvnc-vnc-server wayvnc rpi-connect +sudo apt purge -y realvnc-vnc-server wayvnc rpi-connect rpi-connect-lite +sudo apt autoremove --purge -y # the libraries they leave behind sudo ss -tulnH | awk '{print $1, $5}' | sort -u # tcp 22 and 9100, nothing else ``` @@ -232,6 +269,12 @@ Done on 2026-11-17: it returned `node_arp_entries{device="wlan0"} 1`. The picked up once `prometheus` has converged on `main` (ADR-0021) and reloaded the file, within five minutes of that. Check `up{instance="heimdall"}` reads 1. +The target's `role: display` keeps `InstanceDown` from paging for the Pi. It +also selects four warnings in `rules/host.rules.yaml`, none of which pages: +`DisplayUpdatesStalled` (an origin's upgrades pending for three days), +`DisplayUnitFailed`, `DisplayHot` (the SoC above 75 °C for 15 minutes) and +`DisplayDown` (unscraped for two hours). + ## 5. HDMI Use the micro-HDMI port **next to the USB-C power port** (`HDMI-A-1`). Make @@ -378,6 +421,10 @@ the roadmap's *Everything still to buy* and an ADR of its own. then delete both `nightly-reboot.*` units from `/etc/systemd/system`. - **Raspberry Pi's updates:** delete `/etc/apt/apt.conf.d/52heimdall-unattended-upgrades`. +- **The bootloader:** delete + `/etc/systemd/system/rpi-eeprom-update.service.d/50-always.conf` and + `daemon-reload`. A bootloader already written stays, and the stock + service goes back to writing critical fixes only. - **The journal:** delete `/etc/systemd/journald.conf.d/50-persistent.conf` and restart `systemd-journald`. - **The masked services:** `sudo systemctl unmask` the units §2 masked, then diff --git a/docs/runbooks/deploy-stack.md b/docs/runbooks/deploy-stack.md index 90ba0dfbd..ca1915fe6 100644 --- a/docs/runbooks/deploy-stack.md +++ b/docs/runbooks/deploy-stack.md @@ -151,7 +151,7 @@ Then in the UI: 1. **Prometheus → Status → Targets.** Every job `UP`. The four `snmp` targets take up to 45 seconds on their first scrape. 2. **Prometheus → Status → Rules.** Every rule loaded, none in error. The - page lists 188: the 182 alert rules this repository counts everywhere + page lists 192: the 186 alert rules this repository counts everywhere else, plus the six recording rules: `homelab_suricata_expected_interface`, `homelab_battery_runtime_seconds`, and the two directions each of diff --git a/docs/security.md b/docs/security.md index 2d17aa621..9488f9ee3 100644 --- a/docs/security.md +++ b/docs/security.md @@ -35,7 +35,7 @@ What this network is actually built to survive: | Someone on Winterfell or Hicks logging in to `prometheus` | **Key-only `sshd` since 2026-11-23; no host firewall by decision.** `prometheus` holds the estate's CA key and the age key that opens every volume backup set, and converge runs as the operator, who is in `sudo` and `docker`. Its `sshd` answers all of Hicks (by `morpheus`'s pass for `22` to the segment) and every host on VLAN 99. The audit's root-only reads on 2026-11-23 found it taking passwords, with X11 forwarding on and `ufw` inactive. [ADR-0128](adr/0128-give-prometheus-a-key-only-sshd-and-no-host-firewall.md) makes `sshd` key-only through a drop-in that outranks cloud-init's, refusing root and X11 forwarding ([`restore-the-stack.md`](runbooks/restore-the-stack.md#make-sshd-key-only)). It adds no host firewall, because Docker's rules run ahead of `ufw`'s for the published ports, so a policy would cover `22` alone. Those ports stay fenced as before: by `morpheus` by destination, by the ingest proxy's tokens on `9090` and `3100`, and on `6514` by the syslog listener's pinned client certificate and its sender list. The step was applied the same day. `sshd -T` read `no` for all four settings, a password login and a keyboard-interactive login were each refused with `Permission denied (publickey)`, and a key login from Hicks succeeded after the reload. | | Someone on Hicks or Winterfell logging in to `smaug` | **Key-only `sshd` since 2026-11-24.** `smaug` holds the household's media and the `erebor` pool. Two hosts reach its `22`, each by a host-scoped pass on `morpheus` ([`network.md`](network.md)): `prometheus`, as the read-only backup user `frodo`, and `desktop-02` on Hicks, as the administrator `gerrrt`. From 2026-11-13 `gerrrt` logged in by password, allowed both on the user and in the SSH service's *Password Login Groups*, while the documents said `frodo` was the only user. Both settings were cleared in the TrueNAS UI on 2026-11-24. `sshd_config` then had no `Match` block left, and a connection as `gerrrt` or `root` was offered `publickey` alone. | | 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 | 210 alert rules, 30 days of metrics and logs | +| Losing visibility of a failure | 214 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 71f3d8423..15426b009 100644 --- a/stacks/observability/README.md +++ b/stacks/observability/README.md @@ -53,7 +53,7 @@ prometheus/ targets/snmp.yaml SNMP targets — hot-reloaded, no restart needed targets/node.yaml node_exporter scrapes, for the host that runs no Alloy (smaug) targets/blackbox*.yaml probe targets, http, dns and latency — hot-reloaded, no restart - rules/*.rules.yaml 182 alert rules: host, network, ups, containers, blackbox, + rules/*.rules.yaml 186 alert rules: host, network, ups, containers, blackbox, dns, backup, ids, deploy, stack, internet, watchdog and range tests/*.test.yaml promtool unit tests — assert the rules can fire blackbox/blackbox.yaml probe modules — reachability, and what a resolver said diff --git a/stacks/observability/prometheus/rules/host.rules.yaml b/stacks/observability/prometheus/rules/host.rules.yaml index 768b9fd8e..4551cd406 100644 --- a/stacks/observability/prometheus/rules/host.rules.yaml +++ b/stacks/observability/prometheus/rules/host.rules.yaml @@ -274,6 +274,97 @@ groups: older than the installed one until this happens. Pick a window — rebooting the monitoring host blinds the estate for its duration. + # --- The wall display (role="display", `heimdall`, ADR-0119) ----------- + # InstanceDown leaves the display out, because a dead screen shows itself + # to anyone in the office. What it does not show is the Pi's own state: + # a browser that stopped updating, a unit that failed, a card running + # hot. The 2026-11-24 re-check found that heimdall exported all three + # (apt.prom from prometheus-node-exporter-collectors, the systemd and + # hwmon collectors) and that no rule read any of them. These four are + # warnings: they reach the default channel, or security for updates, and + # none of them pages. None needs a host label: the display is scraped + # directly, so `instance` names it. + + - alert: DisplayUpdatesStalled + # The wall runs Chromium all day on Hicks, and ADR-0119's case for + # that rests on the browser taking its updates unattended. The Pi + # installs them every morning and reboots onto them at 04:30, so an + # upgrade is normally pending for under a day. Three days of the same + # origin pending means unattended-upgrades stopped, an upgrade is held, + # or the origin fell out of build-heimdall.md §2's allow list, as it was + # until 2026-11-23. + expr: apt_upgrades_pending{role="display"} > 0 + for: 3d + labels: + component: host + severity: warning + category: security + annotations: + summary: "{{ $labels.instance }}: {{ $value }} upgrade(s) from {{ $labels.origin }} pending three days" + description: >- + unattended-upgrades runs every morning and should have installed + these. On the Pi, read /var/log/unattended-upgrades/unattended-upgrades.log + and check `apt-config dump | grep Origins-Pattern` still names + the origin (build-heimdall.md §2). + + - alert: DisplayUnitFailed + # heimdall is the one host here that exports node_systemd_unit_state, + # so a failed unit on it is visible to Prometheus and nowhere else: it + # ships no journal to Loki, where SystemdUnitFailed would see it. + expr: node_systemd_unit_state{role="display", state="failed"} == 1 + for: 15m + labels: + component: host + severity: warning + category: availability + annotations: + summary: "{{ $labels.name }} has failed on {{ $labels.instance }}" + description: >- + `systemctl --failed` and `journalctl -b -u {{ $labels.name }}` on + the Pi. The journal is kept across reboots (build-heimdall.md §2), + so the cause survives the 04:30 reboot. + + - alert: DisplayHot + # The Pi 5 starts throttling its cores at 80 °C. Over a week on the + # wall, heimdall's SoC peaked at 58 °C, so 75 °C for a quarter of an + # hour means a blocked vent or a dead fan, while there is still time. + # The SoC is thermal_zone0. The other chip, RP1's ADC, runs a few + # degrees warmer and is not what throttles. Its two sensors read + # alike, so `max by` gives one alert, not two. + expr: | + max by (instance, role) ( + node_hwmon_temp_celsius{role="display", chip="thermal_thermal_zone0"} + ) > 75 + for: 15m + labels: + component: host + severity: warning + category: availability + annotations: + summary: "{{ $labels.instance }} has been above 75 °C for 15 minutes" + description: >- + {{ $value | printf "%.1f" }} °C on the SoC. It throttles at 80 °C. + Check the fan and the space around the Pi, and + `vcgencmd get_throttled` on it. + + - alert: DisplayDown + # InstanceDown leaves the display out, and a dead screen does show + # itself, but only to someone in the room. Down overnight or over a + # weekend, nobody sees it until the next time they look. The nightly + # reboot takes half a minute, and the longest Wi-Fi gap the audit found + # was ten minutes, so two hours is neither. + expr: up{role="display"} == 0 + for: 2h + labels: + component: host + severity: warning + category: availability + annotations: + summary: "{{ $labels.instance }} has not answered a scrape for two hours" + description: >- + The wall Pi is off, off Hicks, or its exporter stopped. Look at the + wall first, then `ssh` to it from Hicks (build-heimdall.md). + - alert: PatchStateStopped # A host that WAS reporting patch state and no longer is. # diff --git a/stacks/observability/prometheus/targets/node.yaml b/stacks/observability/prometheus/targets/node.yaml index 31f4ed4a5..b90da47dd 100644 --- a/stacks/observability/prometheus/targets/node.yaml +++ b/stacks/observability/prometheus/targets/node.yaml @@ -113,8 +113,11 @@ # answered with node_arp_entries{device="wlan0"} 1. # # `role: display` is what keeps InstanceDown from paging for it -# (rules/host.rules.yaml): a dead screen shows itself, and what this scrape is -# for is the Pi's temperature and throttle state on a wall nobody watches. +# (rules/host.rules.yaml): a dead screen shows itself. The same label selects +# the four Display* warnings there, on what the wall does not show: the SoC's +# temperature, upgrades left pending, a failed unit, and two hours unscraped. +# node_exporter does not report the throttle state. That is +# `vcgencmd get_throttled`, read on the Pi. - targets: ["10.0.50.15:9100"] labels: diff --git a/stacks/observability/prometheus/tests/host.test.yaml b/stacks/observability/prometheus/tests/host.test.yaml index 7cede3413..12c602886 100644 --- a/stacks/observability/prometheus/tests/host.test.yaml +++ b/stacks/observability/prometheus/tests/host.test.yaml @@ -196,9 +196,9 @@ tests: exp_alerts: [] # --- InstanceDown: quiet for the wall display, which does not page -------- - # `heimdall` (ADR-0119) is scraped for its temperature and throttle state, - # not watched for liveness: a dead screen shows itself to anyone in the - # office. Down for twenty minutes, well past `for: 5m`, and still quiet. + # `heimdall` (ADR-0119) does not page when down: a dead screen shows itself + # to anyone in the office, and DisplayDown below warns after two hours. + # Down for twenty minutes, well past `for: 5m`, and still quiet. # The smaug case below, with no `role`, is the pair that proves the # exclusion is that narrow. - interval: 1m @@ -210,6 +210,138 @@ tests: alertname: InstanceDown exp_alerts: [] + # --- DisplayDown: the same Pi, down for two hours, does warn ------------- + # The display's own down rule, at warning. Down for 2h10m it fires, and + # the pair inside `for: 2h` is quiet: the nightly reboot and a Wi-Fi gap + # are both far shorter. + - interval: 5m + input_series: + - series: 'up{instance="heimdall",job="node",role="display",vlan="50"}' + values: "0x30" + alert_rule_test: + - eval_time: 130m + alertname: DisplayDown + exp_alerts: + - exp_labels: + instance: heimdall + job: node + role: display + vlan: "50" + component: host + severity: warning + category: availability + exp_annotations: + summary: "heimdall has not answered a scrape for two hours" + description: >- + The wall Pi is off, off Hicks, or its exporter stopped. Look at the + wall first, then `ssh` to it from Hicks (build-heimdall.md). + - eval_time: 110m + alertname: DisplayDown + exp_alerts: [] + + # --- DisplayUpdatesStalled: the same origin pending for three days -------- + # The firing series stays above zero for 80 hours. The quiet one is the + # normal day: pending from the morning run until the next one clears it, + # then pending again, never three days at a stretch. Samples every 5m, as + # scraped: a series unsampled for longer goes stale and resets `for`. + - interval: 5m + input_series: + - series: >- + apt_upgrades_pending{instance="heimdall",job="node",role="display",vlan="50", + origin="Raspberry Pi Foundation:trixie/stable",arch="arm64"} + values: "16x960" + - series: 'apt_upgrades_pending{instance="heimdall",job="node",role="display",vlan="50",origin="Debian:trixie/stable",arch="arm64"}' + values: "2x252 0x36 3x252 0x36 1x252 0x144" + alert_rule_test: + - eval_time: 76h + alertname: DisplayUpdatesStalled + exp_alerts: + - exp_labels: + instance: heimdall + job: node + role: display + vlan: "50" + origin: "Raspberry Pi Foundation:trixie/stable" + arch: arm64 + component: host + severity: warning + category: security + exp_annotations: + summary: "heimdall: 16 upgrade(s) from Raspberry Pi Foundation:trixie/stable pending three days" + description: >- + unattended-upgrades runs every morning and should have installed + these. On the Pi, read /var/log/unattended-upgrades/unattended-upgrades.log + and check `apt-config dump | grep Origins-Pattern` still names + the origin (build-heimdall.md §2). + - eval_time: 70h + alertname: DisplayUpdatesStalled + exp_alerts: [] + + # --- DisplayUnitFailed: a failed unit for longer than 15 minutes ---------- + # openipmi.service failed at every boot on the first build (2026-11-17). + # The pair is the same unit inactive, the state it reports when fine. + - interval: 5m + input_series: + - series: 'node_systemd_unit_state{instance="heimdall",job="node",role="display",vlan="50",name="openipmi.service",state="failed",type="oneshot"}' + values: "1x6" + - series: 'node_systemd_unit_state{instance="heimdall",job="node",role="display",vlan="50",name="ssh.service",state="failed",type="notify"}' + values: "0x6" + alert_rule_test: + - eval_time: 20m + alertname: DisplayUnitFailed + exp_alerts: + - exp_labels: + instance: heimdall + job: node + role: display + vlan: "50" + name: openipmi.service + state: failed + type: oneshot + component: host + severity: warning + category: availability + exp_annotations: + summary: "openipmi.service has failed on heimdall" + description: >- + `systemctl --failed` and `journalctl -b -u openipmi.service` on + the Pi. The journal is kept across reboots (build-heimdall.md §2), + so the cause survives the 04:30 reboot. + - eval_time: 10m + alertname: DisplayUnitFailed + exp_alerts: [] + + # --- DisplayHot: the SoC above 75 °C for 15 minutes ----------------------- + # Two SoC sensors reading alike give one alert. The RP1 ADC, hotter but not + # what throttles, is left out: at 74 °C on the SoC and 79 °C on RP1, quiet. + - interval: 5m + input_series: + - series: 'node_hwmon_temp_celsius{instance="heimdall",job="node",role="display",vlan="50",chip="thermal_thermal_zone0",sensor="temp0"}' + values: "74x4 78x6" + - series: 'node_hwmon_temp_celsius{instance="heimdall",job="node",role="display",vlan="50",chip="thermal_thermal_zone0",sensor="temp1"}' + values: "74x4 78x6" + - series: 'node_hwmon_temp_celsius{instance="heimdall",job="node",role="display",vlan="50",chip="1000120000_pcie_1f000c8000_adc",sensor="temp1"}' + values: "79x10" + alert_rule_test: + - eval_time: 45m + alertname: DisplayHot + exp_alerts: + - exp_labels: + instance: heimdall + role: display + component: host + severity: warning + category: availability + exp_annotations: + summary: "heimdall has been above 75 °C for 15 minutes" + description: >- + 78.0 °C on the SoC. It throttles at 80 °C. + Check the fan and the space around the Pi, and + `vcgencmd get_throttled` on it. + - eval_time: 20m + alertname: DisplayHot + exp_alerts: [] + # --- InstanceDown: fires for a SCRAPED HOST, naming it rather than its port - # `smaug` is the estate's first scraped host (#256, ADR-0016): CasaBonita is # terminal-outward, so the NAS cannot push and Prometheus reaches in over From 6760c647b9508b021cbcbee3cfaa3f71b3c42f10 Mon Sep 17 00:00:00 2001 From: Gerrrt Date: Tue, 24 Nov 2026 13:19:18 -0800 Subject: [PATCH 2/2] fix(alerts): bridge heimdall's nightly reboot in DisplayUpdatesStalled A failed scrape at the 04:30 reboot marks apt_upgrades_pending stale, which reset the three-day timer every night, so the alert could never fire. Read max_over_time over 15 minutes instead, and test it with a stale sample each day. Co-Authored-By: Claude Opus 5.5 --- .../prometheus/rules/host.rules.yaml | 10 +++++++++- .../observability/prometheus/tests/host.test.yaml | 15 +++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/stacks/observability/prometheus/rules/host.rules.yaml b/stacks/observability/prometheus/rules/host.rules.yaml index 4551cd406..d6c33910f 100644 --- a/stacks/observability/prometheus/rules/host.rules.yaml +++ b/stacks/observability/prometheus/rules/host.rules.yaml @@ -293,7 +293,15 @@ groups: # origin pending means unattended-upgrades stopped, an upgrade is held, # or the origin fell out of build-heimdall.md §2's allow list, as it was # until 2026-11-23. - expr: apt_upgrades_pending{role="display"} > 0 + # + # `max_over_time` over 15 minutes, not the bare series, because the + # bare series would reset `for` every night. The 04:30 reboot fails a + # scrape, which marks the series stale (on 2026-11-24, `up` read 0 + # there), and a three-day timer that restarts daily never fires. The + # window bridges the reboot. When an origin's upgrades go in, the + # collector writes no series for it at all, not a 0, so the window + # empties 15 minutes later and the timer resets as it should. + expr: max_over_time(apt_upgrades_pending{role="display"}[15m]) > 0 for: 3d labels: component: host diff --git a/stacks/observability/prometheus/tests/host.test.yaml b/stacks/observability/prometheus/tests/host.test.yaml index 12c602886..bb896ea7c 100644 --- a/stacks/observability/prometheus/tests/host.test.yaml +++ b/stacks/observability/prometheus/tests/host.test.yaml @@ -240,18 +240,21 @@ tests: exp_alerts: [] # --- DisplayUpdatesStalled: the same origin pending for three days -------- - # The firing series stays above zero for 80 hours. The quiet one is the - # normal day: pending from the morning run until the next one clears it, - # then pending again, never three days at a stretch. Samples every 5m, as - # scraped: a series unsampled for longer goes stale and resets `for`. + # The firing series stays above zero for 80 hours, except that each night's + # reboot fails one scrape and marks it stale, as on 2026-11-24. The bare + # series would restart `for` at every one; the 15-minute window must not. + # The quiet one is the normal day: pending from the morning run until the + # next one installs it, when the collector stops writing the series (it + # writes no 0), then pending again, never three days at a stretch. Samples + # every 5m, as scraped. - interval: 5m input_series: - series: >- apt_upgrades_pending{instance="heimdall",job="node",role="display",vlan="50", origin="Raspberry Pi Foundation:trixie/stable",arch="arm64"} - values: "16x960" + values: "16x286 stale 16x286 stale 16x286 stale 16x100" - series: 'apt_upgrades_pending{instance="heimdall",job="node",role="display",vlan="50",origin="Debian:trixie/stable",arch="arm64"}' - values: "2x252 0x36 3x252 0x36 1x252 0x144" + values: "2x252 _x36 3x252 _x36 1x252 _x144" alert_rule_test: - eval_time: 76h alertname: DisplayUpdatesStalled