Skip to content

feat(observability): the range monitoring of ADR-0126 (#1651) - #1679

Merged
Gerrrt merged 3 commits into
mainfrom
gerrrt/monitor-gandalf-build
Nov 23, 2026
Merged

Gerrrt merged 3 commits into
mainfrom
gerrrt/monitor-gandalf-build

Conversation

@Gerrrt

@Gerrrt Gerrrt commented Nov 23, 2026

Copy link
Copy Markdown
Owner

What changed

The repo half of #1651 — the collector, rules, tests and docs ADR-0126 commissions. Fully testable here; the live deploy (firewall pass, metrics-only agent, converge) is flagged below.

  • scripts/collect-range-state.sh (new): reads gandalf's own range controls — the vmbr1_host_in ingress barrier, vmbr0 and sshd forwarding, and the ragnarok stop timer with its effective deadline. Host-only (ADR-0028 class), with a --self-test for its parsers.
  • scripts/ragnarok-stop.sh: a deadline-epoch subcommand so the monitor reads the timer's own effective deadline (extensions and dpkg waits folded in) rather than a second copy of the logic. New self-test fixtures.
  • range.rules.yaml + range.test.yaml (new): six alerts, each with a firing and a quiet promtool test —
    • PveFirewallZeroRules — firewall enabled, DROP policy, zero host rules (the metric existed; no rule read it).
    • RangeIngressBarrierDown, RangeHostForwardingOn, RangeSshForwardingOn — the §2/§4 controls the firewall collector can't see.
    • RagnarokStopTimerInactive, RagnarokPastDeadline — the ADR-0125 timer failing (not a fixed 12h bound).
  • install-agent-collectors.sh: a range-state row.
  • build-the-playground.md §7: a Monitoring the host subsection — the morpheus pass, the host-only collector install (no guest-disk-state), and the metrics-only agent requirement. Marked not yet deployed.
  • Docs/counts trued up: observability.md (the rule file + table row), README, security.md, deploy-stack.md, the stack README, scripts/README, self-tests prose, and the changelog.

Host uptime is deliberately not alerted — an always-on host has no "up too long" fault (ADR-0126).

Also trues up an inherited count

origin/main had 127 ADR files (ADR-0127 merged) but README still said "126 ADRs" — check_docs was red on main. This bumps it to 127 so the tree is consistent.

Refs #1651.

Still to deploy (needs the lab and the firewall — not in this PR)

  • The morpheus pass 10.0.30.30 → 10.0.99.20:9090, metrics only.
  • A metrics-only Alloy config + deploy check: the estate's config.alloy ships journal/auth/var logs to Loki, and the range host must not ship its logs. deploy-agent.sh needs a metrics-only mode. Do not deploy the standard agent to gandalf before this exists.
  • Install the collectors on gandalf and converge prometheus.

Blast radius

Repo only; nothing deploys until the steps above run. New alerts begin evaluating instance="gandalf" once the collector reports, after deploy.

  • No change to network segmentation or firewall rules (the morpheus pass is documented, not applied)
  • No new port published to a VLAN that could not already reach the service
  • No credential added outside secrets/*.sops.yaml

Verification

  • make validate passes. Not run (no docker on this Mac). What ran:
    • python3 scripts/check_docs.py: docs OK (172 Prometheus + 26 Loki rules).
    • promtool test rules on range.test.yaml: SUCCESS; promtool check rules on all files: valid.
    • python3 scripts/check_rule_tests.py: every one of 210 alerts is selected by a test.
    • collect-range-state.sh --self-test (11) and ragnarok-stop.sh --self-test (29): pass.
    • markdownlint-cli2 0.24.1: 0 issues. shellcheck: clean.
    • ./scripts/lint.sh: yamllint, ruff, shellcheck, actionlint pass; ansible-lint fails on the same local runner error as before (no Ansible here); markdownlint/zizmor/packer/tofu skipped (docker).
  • Deployed to the lab and confirmed working. No — the deploy steps above are the follow-on.
  • Docs updated

🤖 Generated with Claude Code

…oyed (#1651)

A collector for gandalf's own controls (collect-range-state.sh: the vmbr1
ingress barrier, vmbr0/sshd forwarding, and the ragnarok stop timer), a
deadline-epoch subcommand on ragnarok-stop.sh so the monitor reads the
timer's own effective deadline, and six range.rules.yaml alerts with
promtool tests: PveFirewallZeroRules, the barrier/forwarding checks, and the
stop timer failing. install-agent-collectors.sh gains the row; §7 gains the
host-only install steps. Not host uptime — an always-on host has no fault
there. Counts trued up, including the inherited 126->127 ADR count.

The morpheus pass, a metrics-only Alloy config, and the live deploy need the
lab and are flagged, not in this change.

Refs #1651.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 23, 2026 18:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Missing systemd units break installation, while collector error handling, forwarding detection, and missing freshness alerts can leave unsafe conditions unreported.

6 open issues
What changed in this PR

Implements the repository-side monitoring for always-on range host gandalf under ADR-0126. Live deployment remains deferred until the firewall pass and metrics-only agent support are ready.

Changes:

  • Adds a host-control collector and machine-readable Ragnarok stop deadline.
  • Adds six Prometheus alerts with firing and quiet test cases.
  • Documents deployment prerequisites and updates alert and ADR counts.
File Description
stacks/​observability/​README.md Updates alert count and adds range coverage.
stacks/​observability/​prometheus/​tests/​range.test.yaml Tests firing and quiet cases for six alerts.
stacks/​observability/​prometheus/​rules/​range.rules.yaml Adds firewall, forwarding, ingress, and stop-timer alerts.
scripts/​self-tests.sh Documents the new collector’s parser fixtures.
scripts/​README.md Lists the range-state collector.
scripts/​ragnarok-stop.sh Adds deadline-epoch output and fixtures.
scripts/​install-agent-collectors.sh Registers the range-state collector.
scripts/​collect-range-state.sh Exports range host controls and stop-timer metrics.
README.md Updates alert and ADR totals.
docs/​security.md Updates the alert total.
docs/​runbooks/​deploy-stack.md Updates expected loaded-rule count.
docs/​runbooks/​build-the-playground.md Documents host-only monitoring and pending deployment prerequisites.
docs/​observability.md Documents range alerts and updates coverage counts.
docs/​changelog.md Records implementation and outstanding deployment work.

Review effort: Balanced

Comment thread scripts/collect-range-state.sh Resolved
Comment thread scripts/collect-range-state.sh Resolved
Comment thread scripts/collect-range-state.sh Resolved
Comment thread scripts/install-agent-collectors.sh Resolved
Gerrrt and others added 2 commits November 23, 2026 10:31
…eview

Review on #1679:
- Add systemd/agent/homelab-range-state.{service,timer}; the installer
  requires the unit pair for every row, so without it --only range-state and
  every default install failed.
- collect-range-state.sh: survive an absent nft table under set -e; treat a
  failed or malformed deadline-epoch as unknown, not a stopped VM; and
  AllowTcpForwarding local/remote now count as forwarding on (only no is off).
- The stop timer records a dpkg deferral; the collector exports it and
  RagnarokPastDeadline excludes it, so a protected install past the deadline
  does not read as a failed timer.
- Add RangeStateStale: the textfile exporter keeps serving old values when the
  collector stops, so a barrier that falls afterwards would read healthy.
- §7 upgrades the stop helper before the collector; counts trued up.

Refs #1651.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…f-build

# Conflicts:
#	README.md
#	docs/changelog.md
@Gerrrt
Gerrrt merged commit cb23bad into main Nov 23, 2026
9 checks passed
@Gerrrt
Gerrrt deleted the gerrrt/monitor-gandalf-build branch November 23, 2026 18:56
Gerrrt added a commit that referenced this pull request Nov 23, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants