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
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,14 @@ recipient-state: ## Record which age recipients can open the secrets, and when e
@# is what sets a proof.
./scripts/key-recipients.sh --record --stack $(STACK)

.PHONY: workflow-state
workflow-state: ## Record whether GitHub still runs the scheduled workflows, and the audit token's expiry
@# Asks GitHub's public API, anonymously, for each scheduled workflow's state
@# and newest finished scheduled run, and writes github-workflows.prom into
@# the textfile dir. ScheduledWorkflowStale, ScheduledWorkflowDisabled and
@# AuditTokenExpiringSoon read it. ARGS=--stdout prints instead of writing.
./scripts/collect-workflow-state.py $(ARGS)

.PHONY: ca-key-state
ca-key-state: ## Record the estate CA key's fingerprint and when a copy of it was last proved (#496)
@# The CA-key twin of recipient-state. Reads the PUBLIC certificate, hashes
Expand Down
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
215 alert rules — 187 metric-based in Prometheus, 28 log-based in Loki — sharing
218 alert rules — 190 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
Expand Down Expand Up @@ -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, 187 alert rules
│ │ ├── prometheus/ # config, file_sd targets, 190 alert rules
│ │ ├── alertmanager/ # routing and inhibition
│ │ ├── loki/ # single-binary config + 28 LogQL rules
│ │ ├── alloy/ # the agent config directory, shipped to every host
Expand Down
17 changes: 17 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,23 @@ docstring gives: it is a record, not a claim about now.
service is named in its stack's README, and the alert counts, scrape jobs,
dashboards, Alertmanager receivers and the ports and paths that runbooks name
in `stacks/` all matched. Ledger: `docs/audit/FINDINGS.md`.

- **The scheduled GitHub workflows have a heartbeat.** cve-scan, digests, the
weekly audit, wiki-watch and Scorecard run only on GitHub's schedule.
GitHub stops a public repository's schedules after 60 days without
activity and tells nobody. A new daily job, `workflow-state`
(`scripts/collect-workflow-state.py`), records each workflow's state and
newest finished scheduled run from the public API. Three warnings read it:
`ScheduledWorkflowStale`, `ScheduledWorkflowDisabled`, and
`AuditTokenExpiringSoon`, which fires 30 days before the audit's one-year
`CLAUDE_CODE_OAUTH_TOKEN` lapses. The issue date in the script is
2026-11-26, the day the audit was added (#1773). The clock is "last run",
not "last success": the first live read found `digests` had failed on each
of the four Mondays since 2026-11-02. Each failure was reported, and none
of them means the schedule stopped. 190 Prometheus rules now, 218 in all.
[`schedule-maintenance.md`](runbooks/schedule-maintenance.md#the-workflows-github-runs-and-the-audits-token)
has the rotation steps.

- **Weekly docs audit, week 2026-48, stacks (second pass).** Three current-state
documents still called MakeMKV undeployed after the 2026-11-28 entry
recorded it deployed and its `Allow 5800 to smaug` pass created:
Expand Down
8 changes: 4 additions & 4 deletions 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

215 rules in total: 187 metric-based in `prometheus/rules/`, and 28 log-based in
218 rules in total: 190 metric-based in `prometheus/rules/`, and 28 log-based in
`loki/rules/`.

### Log-based (Loki ruler)
Expand Down Expand Up @@ -551,7 +551,7 @@ argument and for what to do when it exits 1.

### Metric-based (Prometheus)

187 rules across 13 files in `prometheus/rules/`:
190 rules across 13 files in `prometheus/rules/`:

| File | Covers |
| --- | --- |
Expand All @@ -563,7 +563,7 @@ argument and for what to do when it exits 1.
| `watchdog.rules.yaml` | One rule that always fires, so that its absence is detectable |
| `blackbox.rules.yaml` | Whether an endpoint can actually be reached, from outside the service, and how many days its certificate has left — the sensitive tier's seven-day ACME leaves excepted, which an hours pair watches for a stalled renewal instead — `TlsAcmeRenewalLate` at 48h, `TlsAcmeRenewalStalled` at 36h ([#426](https://github.com/Gerrrt/HomeLab/issues/426)) — Grafana and the wiki verified against the lab CA ([#847](https://github.com/Gerrrt/HomeLab/issues/847)), the APC card's verified against the same CA since 2026-11-24, Prometheus, Loki and Alertmanager over plain http (the switch UI's probes were removed on 2026-09-06, `targets/blackbox.yaml`), each of the household sites behind `trinity`'s Caddy, verified against the tier's root, paging as `SiteDown` after ten minutes so a `make up` restart does not ([#855](https://github.com/Gerrrt/HomeLab/issues/855)), and — the other way round — that the ingest proxy on `10.0.99.20:9090` and `:3100` still refuses a request with no token (`IngestAuthNotEnforced`, [#182](https://github.com/Gerrrt/HomeLab/issues/182)). `EeroUnreachable` is a warning for an eero unit that has not answered ping for five minutes, from the `blackbox-eero` job, through one Winterfell pass in force since 2026-11-11 ([#1228](https://github.com/Gerrrt/HomeLab/issues/1228), [ADR-0112](adr/0112-probe-the-eeros-by-icmp-from-prometheus.md)). The iLO and pfSense UIs are written into `targets/blackbox.yaml` and left disabled: each needs a firewall pass from `10.0.99.20` that is a segmentation decision, not a monitoring one ([#91](https://github.com/Gerrrt/HomeLab/issues/91)). Their certificates' expiry is watched without that pass, from `host.rules.yaml` ([#857](https://github.com/Gerrrt/HomeLab/issues/857)) |
| `dns.rules.yaml` | Whether the house is still filtering DNS, asked directly at AdGuard Home on port 53 rather than through pfSense. Since [ADR-0055](adr/0055-forward-to-adguard-alone.md) AdGuard is the only forwarder, so `AdGuardNotAnswering` is **critical** at five minutes: the house cannot resolve outside names. `AdGuardNotFiltering` stays a warning, because a filter that fails open is a convenience lost, not an outage. The targets in `targets/blackbox-dns.yaml` are live since 2026-09-28, against AdGuard on `trinity` ([#126](https://github.com/Gerrrt/HomeLab/issues/126), [#404](https://github.com/Gerrrt/HomeLab/issues/404)) |
| `backup.rules.yaml` | Whether the scheduled maintenance jobs are still being run at all — staleness, failure, never-ran, and the page: `ScheduledJobStaleCritical` at three of a job's own periods and never under a day, because the warning reaches only the in-house channel and a backup that stopped in week one was otherwise a notification repeating on the same network for as long as nobody acted (2026-10-14) — whether the CA key's offline copy has been proved lately ([#496](https://github.com/Gerrrt/HomeLab/issues/496)), and whether the newest backup sets have been carried onto the offsite drive within ninety days ([ADR-0048](adr/0048-carry-the-estates-backup-sets-with-the-second-recipient.md), [ADR-0132](adr/0132-carry-the-offsite-copy-on-the-spare-drive.md)) |
| `backup.rules.yaml` | Whether the scheduled maintenance jobs are still being run at all — staleness, failure, never-ran, and the page: `ScheduledJobStaleCritical` at three of a job's own periods and never under a day, because the warning reaches only the in-house channel and a backup that stopped in week one was otherwise a notification repeating on the same network for as long as nobody acted (2026-10-14) — whether the CA key's offline copy has been proved lately ([#496](https://github.com/Gerrrt/HomeLab/issues/496)), and whether the newest backup sets have been carried onto the offsite drive within ninety days ([ADR-0048](adr/0048-carry-the-estates-backup-sets-with-the-second-recipient.md), [ADR-0132](adr/0132-carry-the-offsite-copy-on-the-spare-drive.md)). Also whether GitHub still runs the five scheduled workflows, which no timer here runs: `ScheduledWorkflowStale` when no scheduled run has finished in nine days, `ScheduledWorkflowDisabled` when GitHub has turned a schedule off, and `AuditTokenExpiringSoon` 30 days before the weekly audit's one-year Claude token lapses, all from `scripts/collect-workflow-state.py` |
| `deploy.rules.yaml` | Whether each host that pulls — `prometheus` and `trinity` ([#533](https://github.com/Gerrrt/HomeLab/issues/533)) — is running what the repository says: an uncommitted edit made on the host, a revision that did not verify, and how far behind `main` it is, and a host whose record stopped arriving. Reads the record `scripts/converge.sh` writes hourly ([#99](https://github.com/Gerrrt/HomeLab/issues/99), [ADR-0021](adr/0021-converge-on-a-timer-instead-of-deploying-over-ssh.md)). Also whether convergence had to start a stack service that something stopped — `DeployServiceRevived` — and whether one has been left stopped for two hours, held or under a backup — `DeployServicesStopped` ([ADR-0087](adr/0087-start-a-stopped-stack-service-from-the-converge-timer.md)) |
| `internet.rules.yaml` | Why the internet is slow ([#914](https://github.com/Gerrrt/HomeLab/issues/914)): three scheduled speed tests in a row under 400 Mbit/s down or 100 up, the WAN held above 85% of what it can carry, frames arriving corrupted on the WAN port — `WanReceiveErrors`, the fault found the day these were written, when a cable between the XB7 and `morpheus` cut downloads to ~2 Mbit/s — and `speedtest-tracker` itself going quiet or unreachable. Also records `homelab_wan_bits_per_second` from pf's own em0 counters. Download thresholds are against the ~940 Mbit/s the 1000baseT WAN port can carry, not the plan's 2000. `speedtest-tracker` is left out of `InstanceDown`, so its outage is a warning and not a page |
| `range.rules.yaml` | The range host `gandalf`'s own controls, now that it stays on ([ADR-0126](adr/0126-monitor-gandalf-now-that-it-stays-on.md), [#1651](https://github.com/Gerrrt/HomeLab/issues/1651)): the `vmbr1_host_in` ingress barrier, `vmbr0` forwarding and `sshd` forwarding being off (`build-the-playground.md` §2, §4), and the attack-VM stop timer (ADR-0125) — read by `scripts/collect-range-state.sh`. `PveFirewallZeroRules` is here too: the firewall collector exports the rule count but no other rule reads it |
Expand All @@ -588,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 187 rules of 187 so far ([#843](https://github.com/Gerrrt/HomeLab/issues/843)) — all twelve
against the broken rule too. Coverage is 190 rules of 190 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
Expand Down
2 changes: 1 addition & 1 deletion docs/runbooks/deploy-stack.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 193: the 187 alert rules this repository counts everywhere
page lists 196: the 190 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
Expand Down
29 changes: 29 additions & 0 deletions docs/runbooks/schedule-maintenance.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ the host.
| `gateway-state` | `make gateway-state` | every 15 minutes | 90 minutes |
| `silence-state` | `make silence-state` | every 15 minutes | 90 minutes |
| `prune-images` | `make prune-images` | Mondays 04:00 | 14 days |
| `workflow-state` | `make workflow-state` | daily 10:00 | 2 days |
| `verify-ca-key-backup` | **you**, `make certs-verify-backup KEY=…` | no timer | 90 days |
| `offsite-copy` | **you**, `make backup-offsite DEST=…` | no timer | 90 days |
| `neo`'s HTTPS leaf | **you**, `make certs ARGS="--host neo.matrix.elysium --ip 10.7.7.2 --force"`, then import it on the switch | no timer; once, before **2029-01-06** | **nothing alerts** |
Expand Down Expand Up @@ -724,6 +725,31 @@ it. Both checks then apply to it, with nothing else to change.

---

### The workflows GitHub runs, and the audit's token

Five workflows run on GitHub's schedule rather than on a timer here:
`cve-scan`, `digests`, `weekly-audit`, `wiki-watch` and `scorecard`. A failed
run is its own notification, because GitHub emails it. A schedule that has
stopped firing sends nothing, and GitHub stops a public repository's schedules
after 60 days with no activity. `workflow-state` asks the public API every day
for each workflow's state and its newest finished scheduled run, whatever the
conclusion. `digests` fails on purpose when it finds drift, so "last success"
would be the wrong clock. The job writes `github-workflows.prom`. A new
scheduled workflow must be added to `WORKFLOWS` in
`scripts/collect-workflow-state.py`, and its self-test fails until it is.

The same job carries the expiry of `CLAUDE_CODE_OAUTH_TOKEN`, which the weekly
audit uses. `claude setup-token` issues it for one year, and
`AuditTokenExpiringSoon` fires 30 days before it lapses. To rotate it:

1. On a machine signed in to Claude, run `claude setup-token`.
2. `gh secret set CLAUDE_CODE_OAUTH_TOKEN` and paste the token. Do not put it
in a file or a commit.
3. In a PR, change `CLAUDE_OAUTH_TOKEN_ISSUED` in
`scripts/collect-workflow-state.py` to today's date. The alert clears the
day after converge brings that commit here.
4. `gh workflow run weekly-audit.yml` proves the new token.

## Install

```bash
Expand Down Expand Up @@ -945,6 +971,9 @@ expected rather than a second fault.
| `ScheduledJobStaleCritical` | A job has gone three of its own periods without a success — one and a half of the allowance in the `JOBS` table, which is twice the period; a weekly backup three weeks stale, a nightly one three nights, and never under a day for the hourly collectors — and the `ScheduledJobStale` warning for it has been repeating on the in-house channel unanswered | The same first look as the warning: `systemctl list-timers 'homelab-*'`, then `journalctl -u homelab-<job>.service`. The rows below name the usual cause per job. The page holds the warning back while it is up, so a job that recovers clears both at once |
| `OffsiteCopyStale` | Ninety days since the newest sets were last copied to the offsite drive, the spare `HOUSEHOLD` drive ([ADR-0132](../adr/0132-carry-the-offsite-copy-on-the-spare-drive.md)), and proved there | Bring it back, mount it and run `make backup-offsite DEST=…` — [`copy-the-backups-offsite.md`](copy-the-backups-offsite.md). `--list`, `--verify-only` and `--prune` do not clear it, on purpose |
| `CaKeyBackupUnproven` | No offline copy of `certificates/ca-key.pem` has been proved in ninety days — or ever, or not since the CA was re-minted, which the fingerprint label tells apart | Mount the medium and `make certs-verify-backup KEY=…` ([`back-up-the-ca-key.md`](back-up-the-ca-key.md)). After a re-mint, copy the new key there first; the old copy is refused |
| `ScheduledWorkflowDisabled` | GitHub stopped a workflow's schedule after 60 days with no repository activity, or someone turned it off | `gh workflow enable <file>`. Nothing ran in the gap, so run it once by hand too: `gh workflow run <file>` |
| `ScheduledWorkflowStale` | The workflow is enabled but no scheduled run has finished in nine days | Open its page under Actions. A run stuck *queued* is a GitHub Actions incident; no runs at all means the `cron:` line has changed or gone. A failing run does not cause this alert |
| `AuditTokenExpiringSoon` | `CLAUDE_CODE_OAUTH_TOKEN` is within 30 days of its one-year expiry, or past it | Rotate it as [The workflows GitHub runs, and the audit's token](#the-workflows-github-runs-and-the-audits-token) says. The alert clears only once the date in `collect-workflow-state.py` changes |
| `ScheduledJobMetricsAbsent` | Nothing from the textfile directory has reached Prometheus in six hours | This is the whole directory, not one file — check Alloy is up and the directory still exists. A single malformed file shows as `node_textfile_scrape_error 1` and costs only that file |
| One job's series missing, `node_textfile_scrape_error` is 1 | That job's `.prom` failed to parse — a truncated write, or something wrote it without the temp-then-rename | The other files are unaffected. Re-run the job; if it recurs, something is writing the file directly instead of through `run-scheduled.sh` |
| Every `homelab_job_*` series missing, no scrape error | The `textfile` block in `config.alloy` is not reading the right path | It must carry the `ALLOY_ROOTFS` prefix (`/rootfs` in the container). `rootfs_path` does **not** apply to that argument, and a wrong path reports an empty directory rather than an error |
Expand Down
Loading