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
13 changes: 13 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ docstring gives: it is a record, not a claim about now.

## 2026-11-19

- **`eden` reports its patch state again, and the lab's `PatchStateStopped`
leaves it out while it is off.** Redeploying the lab after #1585 put the
alert in pending for `eden`: it reported from 2026-11-08 until 23:04 UTC on
2026-11-12 and not since its rebuild the next morning. The old guest's timer
had been installed by hand, `build-the-bloodhound-guest.md` had no such
step, and the `[1d]` window had cleared the alert by 2026-11-14. §6 now
installs it, and it was installed on `eden`. `eden` is `on-demand` and off
between sessions, so the rule's vanished-series branch leaves it out while
none of its node metrics have arrived in an hour: ADR-0079's decision for
`HypervisorGuestStopped`, brought to the lab, which cannot read `Saruman`'s
tags and names the guest instead. Two promtool cases: an `eden` that is
shut down is quiet at 3 d and 10 d, and an `eden` that is running without
its collector fires.
- **`PatchStateStopped` and `GuestStateStopped` now also fire for a
collector that stops and leaves its file.** The entry below left this open:
a stopped timer leaves its `.prom` file in the textfile directory,
Expand Down
19 changes: 19 additions & 0 deletions docs/runbooks/build-the-bloodhound-guest.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,25 @@ Check each one now:
there means the leaf lacks the `bloodhound` SAN. §7's `up{job="bloodhound"}`
is the same answer from `alexander`.

**Report patch state**, so a held security update or a pending reboot reaches
someone while the guest runs. The lab's `SecurityUpdatesPending`,
`RebootRequired` and `PatchStateStopped` read `apt-patch-state.prom`, and a
guest without the timer is invisible to all three. Until 2026-11-19 this step
was missing: the guest reported until its rebuild on 2026-11-13, from a timer
put there by hand, and not after. `make up` has created the textfile
directory. From the checkout on Hicks, logged in as `garnet`; the installer
asks for its sudo password once:

```bash
make install-agent-collectors AGENT=garnet@10.0.30.41 ARGS='--only patch-state'
```

It must end with `apt-patch-state.prom written, mode 644`. The timer is
`Persistent=true`, so a run missed while the guest was off happens at its next
boot. `PatchStateStopped` names `eden` as on-demand and leaves it out while
none of its node metrics arrive (ADR-0079's reasoning), so shutting it down is
not an alert; a dead collector on a running `eden` still is.

Then shut it down cleanly. That is what "off between sessions" means, and the
first session should start from it:

Expand Down
22 changes: 22 additions & 0 deletions stacks/lab/prometheus/rules/lab.rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,34 @@ groups:
# daily timer, covers one missed run and its jitter. The mtime series
# carries `instance`, not `host`, so label_replace copies one into the
# other. Raised in review on #1544.
#
# ON-DEMAND GUESTS ARE LEFT OUT WHILE THEY ARE OFF, which is ADR-0079's
# decision for HypervisorGuestStopped brought to this rule. `eden` is off
# between sessions, and an off guest pushes nothing, so without this the
# first branch fires six hours after every session ends. The lab cannot
# read Saruman's `on-demand` tag, so the guests are named here, as
# `role="endpoint"` names the domain's in prometheus.yaml: add a Linux
# guest here when it gets the tag and the collector. "Off" is "none of
# its node metrics have arrived in an hour", read from
# node_boot_time_seconds, which every guest's Alloy pushes; a window, not
# an instant, so a late push does not count as a shutdown, and an hour
# is well inside the six hours the branch waits anyway. While the guest is up it is treated like any
# other, so a dead collector on a running `eden` still fires. Only the
# first branch needs this: an off guest's mtime series goes with it, and
# at boot Persistent=true collects within the timer's 15 minutes of jitter,
# inside `for: 30m`.
- alert: PatchStateStopped
expr: >-
(
count by (host) (present_over_time(homelab_apt_upgrades_pending[14d] offset 6h))
unless
count by (host) (present_over_time(homelab_apt_upgrades_pending[6h]))
unless on (host)
(
count by (host) (present_over_time(homelab_apt_upgrades_pending{host=~"eden"}[14d] offset 6h))
unless
count by (host) (present_over_time(node_boot_time_seconds{host=~"eden"}[1h]))
)
)
or
count by (host) (
Expand Down
46 changes: 46 additions & 0 deletions stacks/lab/prometheus/tests/lab.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,52 @@ tests:
alertname: PatchStateStopped
exp_alerts: []

# --- PatchStateStopped: quiet for an on-demand guest that is off ----------
# ADR-0079 for this rule. `eden` reports for 20 hours, then is shut down:
# its patch state and its node metrics stop together. Quiet at 3d and 10d.
- interval: 1h
input_series:
- series: 'homelab_apt_upgrades_pending{host="eden"}'
values: "0x20 _x250"
- series: 'node_boot_time_seconds{host="eden"}'
values: "1x20 _x250"
alert_rule_test:
- eval_time: 3d
alertname: PatchStateStopped
exp_alerts: []
- eval_time: 10d
alertname: PatchStateStopped
exp_alerts: []

# --- PatchStateStopped: fires for an on-demand guest that is up ------------
# The same `eden`, booted again on day 2 with its collector gone: node
# metrics arrive and patch state does not. That is a dead collector on a
# running guest, and it must fire like any other guest's.
- interval: 1h
input_series:
- series: 'homelab_apt_upgrades_pending{host="eden"}'
values: "0x20 _x250"
- series: 'node_boot_time_seconds{host="eden"}'
values: "1x20 _x28 2x220"
alert_rule_test:
- eval_time: 3d
alertname: PatchStateStopped
exp_alerts:
- exp_labels:
host: eden
component: host
severity: warning
category: security
exp_annotations:
summary: "eden has stopped reporting patch state"
description: >-
Its patch state has gone absent, or apt-patch-state.prom has not
been rewritten in two days, so SecurityUpdatesPending and
RebootRequired are reading stale or no data for it. Check
`systemctl status homelab-patch-state.timer` on the guest, and that
/var/lib/node_exporter/textfile_collector/apt-patch-state.prom is
being written and is world-readable.

# --- PatchStateStopped: quiet for a guest that reports zero ----------------
- interval: 5m
input_series:
Expand Down