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

## 2026-11-19

- **`PatchStateStopped` and `GuestStateStopped` no longer clear themselves a
day after a host's series disappears.** Both asked "did this host report in the day
before the last six hours", so about 30 h after the last sample the left
side emptied and the alert resolved with nothing recovered. Review of the
lab's `ApplianceStateStopped` (#1580) found it in that rule, which had
copied the form. Both now look back fourteen days, inside both
Prometheuses' retention (30 d on the estate, 15 d in the lab), so they hold
for two weeks or until the host reports again, and a host that never had
the collector still stays quiet. A host retired on purpose now fires for
those two weeks. New promtool cases fire at 3 d and 10 d and are quiet at
16 d; with `[1d]` put back, the 3 d and 10 d cases fail. This covers a
series that vanishes, not a timer that stops: a stopped timer leaves its
`.prom` file, which is re-served on every scrape, so the series stays. The
lab's `PatchStateStopped` has a second branch on the file's age for that;
the two estate rules do not yet.
- **`SecurityUpdatesPending` went pending for `alexander`, and it is Ubuntu's
phasing.** Three security updates appeared at the 08:01 UTC collection:
`cloud-init`, `cloud-init-base` and `libgstreamer1.0-0`. `apt` lists all
three, with Docker's and others, as "deferred due to phasing":
`alexander` is outside the share of machines the rollout has reached, so
unattended-upgrades leaves them, as it should. Nothing was forced. The rule
fires only if they are still pending a week later.
- **`fenrir`'s cloud-init `sshd` drop-in is removed.**
`50-cloud-init.conf`, 27 bytes reading `PasswordAuthentication yes`, had
been overridden since 2026-11-17 by the `10-homelab.conf` drop-in, which
`sshd` reads first. It was still what an audit without sudo would see, so
`build-the-sensor-guest.md` §3 now removes it and checks that only the
`10-` drop-in is left. cloud-init writes it once per instance; on `fenrir`
it had kept its install date across four reboots.
- **The wall says when the dogs are due.** The last of the wall's five
steps.
- `wall_dogs.yaml` makes `sensor.wall_dogs`: when the dogs were last
Expand Down
11 changes: 9 additions & 2 deletions docs/runbooks/build-the-sensor-guest.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,12 @@ who reaches that port. The installer leaves
`/etc/ssh/sshd_config.d/50-cloud-init.conf` behind, and that file can set
`PasswordAuthentication yes`. `sshd` keeps the **first** value it reads
for each setting, and drop-ins are read in name order, so this file is `10-`
to come before cloud-init's:
to come before cloud-init's. Then remove cloud-init's file as well. The `10-`
drop-in already outranks it, but a 27-byte file that reads
`PasswordAuthentication yes` is what the audit of 2026-11-13 had to guess
from without sudo, and it is the first thing the next one would flag.
cloud-init writes it once per instance, not at each boot: on `fenrir` it kept
its install date across four reboots, so it stays gone.

```bash
sudo tee /etc/ssh/sshd_config.d/10-homelab.conf >/dev/null <<'SSHD'
Expand All @@ -316,11 +321,13 @@ X11Forwarding no
AllowUsers atreus
SSHD
sudo chmod 644 /etc/ssh/sshd_config.d/10-homelab.conf
sudo rm -f /etc/ssh/sshd_config.d/50-cloud-init.conf
sudo sshd -t && sudo systemctl reload ssh
sudo sshd -T | grep -E '^(passwordauthentication|kbdinteractiveauthentication|permitrootlogin|x11forwarding|allowusers) '
```

All five must read `no`, apart from `allowusers atreus`. **Keep the session
All five must read `no`, apart from `allowusers atreus`, and
`ls /etc/ssh/sshd_config.d/` must list only `10-homelab.conf`. **Keep the session
you ran this from open**, and log in from a second terminal before you close
it. If that login fails, VM 190's console in the Proxmox web UI is the way
back in. The VM has no serial port, so `qm terminal 190` is not.
Expand Down
11 changes: 9 additions & 2 deletions stacks/lab/prometheus/rules/lab.rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,14 @@ groups:
# healthiest. Two ways to stop, so two branches:
#
# - The series vanished: Alloy or the textfile directory went. Stopped,
# not missing, so a guest without the timer is not an alert.
# not missing, so a guest without the timer is not an alert. Fourteen
# days of memory, not one, inside this Prometheus's 15d retention: with
# [1d] the alert cleared itself about 30h after the last sample, with
# nothing recovered (review of ApplianceStateStopped, #1580). A guest
# retired on purpose fires for two weeks. This stack has no
# Alertmanager (ADR-0020), so there is nothing to silence: it shows in
# this Prometheus's /alerts and in Grafana until it ages out, and is
# expected there.
# - The file stopped being rewritten. A collector that dies leaves
# apt-patch-state.prom in place and Alloy re-serves its last values on
# every scrape, so the series never goes absent and the first branch
Expand All @@ -271,7 +278,7 @@ groups:
- alert: PatchStateStopped
expr: >-
(
count by (host) (present_over_time(homelab_apt_upgrades_pending[1d] offset 6h))
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]))
)
Expand Down
48 changes: 48 additions & 0 deletions stacks/lab/prometheus/tests/lab.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,54 @@ tests:
/var/lib/node_exporter/textfile_collector/apt-patch-state.prom is
being written and is world-readable.

# --- PatchStateStopped: still firing days later, and gone after two weeks -
# Review of #1580: with [1d] this cleared itself about 30h after the
# collector stopped. Twenty hours of reporting, then 15.5 days of gap.
# Still firing at 3d and 10d; quiet at 16d, past the [14d] window and its
# offset, which is the documented end.
- interval: 1h
input_series:
- series: 'homelab_apt_upgrades_pending{host="odin"}'
values: "3x20 _x380"
alert_rule_test:
- eval_time: 3d
alertname: PatchStateStopped
exp_alerts:
- exp_labels:
host: odin
component: host
severity: warning
category: security
exp_annotations:
summary: "odin 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.
- eval_time: 10d
alertname: PatchStateStopped
exp_alerts:
- exp_labels:
host: odin
component: host
severity: warning
category: security
exp_annotations:
summary: "odin 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.
- eval_time: 16d
alertname: PatchStateStopped
exp_alerts: []

# --- PatchStateStopped: quiet for a guest that reports zero ----------------
- interval: 5m
input_series:
Expand Down
29 changes: 25 additions & 4 deletions stacks/observability/prometheus/rules/host.rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,25 @@ groups:
# continuously and not once a day. Six hours survives a Prometheus
# restart and a host rebooting, which is the same window
# deploy.rules.yaml and backup.rules.yaml settled on.
#
# FOURTEEN DAYS OF MEMORY, NOT ONE. With [1d] the left side empties
# about 30h after the last sample, and the alert cleared itself with
# nothing recovered: a host down for a long weekend came back to no
# record that it had gone quiet. Found in review of the lab's
# ApplianceStateStopped (#1580), which had copied this form. Fourteen
# days sits inside both Prometheuses' retention (30d here, 15d in the
# lab), so the alert holds for two weeks or until the host reports
# again. A host retired on purpose fires for those two weeks; silence
# it when it goes. The cost is a 14d range per host each evaluation,
# one series per host, which this estate's handful of hosts can carry.
#
# WHAT THIS DOES NOT SEE: a timer that stops but leaves its file. The
# file stays in the textfile directory and is re-served on every
# scrape, so the series never goes absent. The lab's copy of this rule
# has a second branch on node_textfile_mtime_seconds for that; this
# one does not yet.
expr: >-
count by (host) (present_over_time(homelab_apt_upgrades_pending[1d] offset 6h))
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]))
for: 30m
Expand All @@ -314,7 +331,7 @@ groups:
annotations:
summary: "{{ $labels.host }} has stopped reporting patch state"
description: >-
It reported within the last day and has not in six hours, so
It reported within the last two weeks and has not in six hours, so
SecurityUpdatesPending and RebootRequired are both blind to this host
until it comes back. Check homelab-patch-state.timer on the host —
`systemctl status homelab-patch-state.timer` — and that
Expand Down Expand Up @@ -1001,8 +1018,12 @@ groups:
#
# Stopped, not missing: a hypervisor that never had the collector
# installed must stay quiet, or every host without it alerts forever.
# Fourteen days of memory, for PatchStateStopped's reason: with [1d]
# the alert cleared itself about 30h after the series went. Like
# PatchStateStopped it sees the series vanish, not a timer that stops
# and leaves guest-state.prom in place.
expr: >-
count by (host) (present_over_time(homelab_guests_total[1d] offset 6h))
count by (host) (present_over_time(homelab_guests_total[14d] offset 6h))
unless
count by (host) (present_over_time(homelab_guests_total[6h]))
for: 30m
Expand All @@ -1013,7 +1034,7 @@ groups:
annotations:
summary: "{{ $labels.host }} has stopped reporting its guests"
description: >-
It reported within the last day and has not in six hours, so
It reported within the last two weeks and has not in six hours, so
HypervisorGuestStopped is blind to this hypervisor until it comes
back. Check homelab-guest-state.timer on the host and that
/var/lib/node_exporter/textfile_collector/guest-state.prom is being
Expand Down
84 changes: 82 additions & 2 deletions stacks/observability/prometheus/tests/host.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -716,14 +716,65 @@ tests:
exp_annotations:
summary: "oracle has stopped reporting patch state"
description: >-
It reported within the last day and has not in six hours, so
It reported within the last two weeks and has not in six hours, so
SecurityUpdatesPending and RebootRequired are both blind to this
host until it comes back. Check homelab-patch-state.timer on the
host — `systemctl status homelab-patch-state.timer` — and that
/var/lib/node_exporter/textfile_collector/apt-patch-state.prom is
being written and is world-readable. A 0600 file is invisible to
the collector and produces exactly this silence.

# --- PatchStateStopped: still firing days later, and gone after two weeks -
# The case review of #1580 found: with [1d] the alert cleared itself about
# 30h after the collector stopped, with nothing recovered. Twenty hours of
# reporting, then 15.5 days of gap (the [14d] window plus its 6h offset and
# a day to spare). Still firing at 3d and 10d; quiet at 16d, once the last
# sample has aged out of the window, which is the documented end.
- interval: 1h
input_series:
- series: 'homelab_apt_upgrades_pending{host="oracle"}'
values: "3x20 _x380"
alert_rule_test:
- eval_time: 3d
alertname: PatchStateStopped
exp_alerts:
- exp_labels:
host: oracle
component: host
severity: warning
category: security
exp_annotations:
summary: "oracle has stopped reporting patch state"
description: >-
It reported within the last two weeks and has not in six hours, so
SecurityUpdatesPending and RebootRequired are both blind to this
host until it comes back. Check homelab-patch-state.timer on the
host — `systemctl status homelab-patch-state.timer` — and that
/var/lib/node_exporter/textfile_collector/apt-patch-state.prom is
being written and is world-readable. A 0600 file is invisible to
the collector and produces exactly this silence.
- eval_time: 10d
alertname: PatchStateStopped
exp_alerts:
- exp_labels:
host: oracle
component: host
severity: warning
category: security
exp_annotations:
summary: "oracle has stopped reporting patch state"
description: >-
It reported within the last two weeks and has not in six hours, so
SecurityUpdatesPending and RebootRequired are both blind to this
host until it comes back. Check homelab-patch-state.timer on the
host — `systemctl status homelab-patch-state.timer` — and that
/var/lib/node_exporter/textfile_collector/apt-patch-state.prom is
being written and is world-readable. A 0600 file is invisible to
the collector and produces exactly this silence.
- eval_time: 16d
alertname: PatchStateStopped
exp_alerts: []

# --- PatchStateStopped: quiet for a host that reports zero -----------------
# The whole point of the rule. A host with nothing to report and a host whose
# collector died look identical in SecurityUpdatesPending and RebootRequired,
Expand Down Expand Up @@ -1791,12 +1842,41 @@ tests:
exp_annotations:
summary: "Saruman has stopped reporting its guests"
description: >-
It reported within the last day and has not in six hours, so
It reported within the last two weeks and has not in six hours, so
HypervisorGuestStopped is blind to this hypervisor until it
comes back. Check homelab-guest-state.timer on the host and that
/var/lib/node_exporter/textfile_collector/guest-state.prom is
being written and is world-readable.

# --- GuestStateStopped: still firing days later, and gone after two weeks -
# PatchStateStopped's long-gap case: with [1d] this cleared itself about
# 30h after the series went. Still firing at 10d; quiet at 16d, so the
# lookback is bounded and a retired hypervisor stops alerting.
- interval: 1h
input_series:
- series: 'homelab_guests_total{host="Saruman"}'
values: "1x20 _x380"
alert_rule_test:
- eval_time: 10d
Comment thread
Gerrrt marked this conversation as resolved.
Resolved
alertname: GuestStateStopped
exp_alerts:
- exp_labels:
host: Saruman
component: host
severity: warning
category: availability
exp_annotations:
summary: "Saruman has stopped reporting its guests"
description: >-
It reported within the last two weeks and has not in six hours, so
HypervisorGuestStopped is blind to this hypervisor until it
comes back. Check homelab-guest-state.timer on the host and that
/var/lib/node_exporter/textfile_collector/guest-state.prom is
being written and is world-readable.
- eval_time: 16d
alertname: GuestStateStopped
exp_alerts: []

# --- GuestStateStopped: quiet for a hypervisor reporting zero guests ------
# The case that makes this rule necessary AND the case it must not fire on.
# Zero is a sample; absence is not.
Expand Down