From 6aa94612466d1d2c50a09718d793ad47aa699788 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 23:10:07 +0000 Subject: [PATCH] feat(sensitive): serve the office wall page, with fixed Prometheus questions stacks/sensitive/wall/ is the trimmed Elysian Wall (ADR-0119): static HTML, CSS and JS, Tokyo Night, six panels sized for the office television at seven feet. Caddy serves it at wall.matrix.elysium. Every number comes from /api/q/NAME, one of eight handles in the Caddyfile that rewrite to a PromQL query written there. Caddy adds the reader token on the way to the ingest proxy and trusts the committed estate CA for that one transport. The client's query string is replaced, only GET and HEAD reach a handle (Prometheus reads a POST body's query= first), and anything else under /api/ is 404. The page and heimdall hold no credential. The page says when it does not know: no answer, or no Watchdog, is shown in red, never as "All quiet". check_caddyfile.sh offers its throwaway CA at the new ingest-ca.pem path too. The blackbox probe is committed commented out until morpheus has the wall host override. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01L2EweeobucQzJcXxXS27K6 --- docs/architecture.md | 2 +- docs/changelog.md | 18 ++ docs/runbooks/build-heimdall.md | 6 +- docs/security.md | 11 + scripts/check_caddyfile.sh | 4 +- .../prometheus/targets/blackbox.yaml | 15 + stacks/sensitive/Caddyfile | 126 ++++++++ stacks/sensitive/README.md | 54 ++++ stacks/sensitive/compose.yaml | 14 + stacks/sensitive/wall/index.html | 79 +++++ stacks/sensitive/wall/wall.css | 227 ++++++++++++++ stacks/sensitive/wall/wall.js | 291 ++++++++++++++++++ 12 files changed, 843 insertions(+), 4 deletions(-) create mode 100644 stacks/sensitive/wall/index.html create mode 100644 stacks/sensitive/wall/wall.css create mode 100644 stacks/sensitive/wall/wall.js diff --git a/docs/architecture.md b/docs/architecture.md index dddf4509..9ff556c1 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -207,7 +207,7 @@ hole from the monitoring VLAN into the monitored one. | `phoenix` (10.0.30.70) | ๐ŸŸข 30 | *(none โ€” a toolchain host, no Docker)* | The deployment host, built 2026-09-20: a Proxmox API token, an SSH key and a checkout, so that the Packer, OpenTofu and Ansible work after [#436](https://github.com/Gerrrt/HomeLab/issues/436) has somewhere to run from. A guest on `Saruman`, placed by [ADR-0043](adr/0043-keep-the-ca-on-prometheus-and-build-phoenix-as-the-deployment-host.md), which also decides that the estate's CA key stays on `prometheus` and does not follow the toolchain here. It holds no age key and runs no continuous convergence (what it configures, it configures on demand, below); it is the WireGuard endpoint of [ADR-0042](adr/0042-terminate-the-remote-path-on-the-lab-and-route-it.md), built 2026-09-22 ([#442](https://github.com/Gerrrt/HomeLab/issues/442)); the one thing it is meant to reach that no other guest does is `8006` on `Saruman`, by a single host-firewall rule โ€” written 2026-09-20, when [#566](https://github.com/Gerrrt/HomeLab/issues/566) enabled the firewall the build had found disabled and narrowed the `local_network` alias that was admitting the whole segment underneath it. Its Alloy pushes to `alexander`, never to VLAN 99; the build is [`build-the-jumpbox.md`](runbooks/build-the-jumpbox.md). The first toolchain on it is [`packer/`](../packer/README.md), the lab's VM templates at VMIDs 901โ€“912, with 903โ€“909 for the dotfiles OS layers ([ADR-0090](adr/0090-test-the-dotfiles-os-layers-on-on-demand-saruman-guests.md)) ([ADR-0074](adr/0074-build-the-lab-templates-with-packer-from-phoenix.md), [`build-the-lab-templates.md`](runbooks/build-the-lab-templates.md)). The second is [`ansible/`](../ansible/README.md), which configures ADR-0029's six over SSH and touches nothing else ([ADR-0077](adr/0077-configure-the-lab-domain-with-ansible-from-phoenix.md), [#448](https://github.com/Gerrrt/HomeLab/issues/448)). Its own way in is decided by [ADR-0117](adr/0117-give-phoenix-a-key-only-sshd-and-a-default-deny-inbound-policy.md): `sshd` takes keys only, and `ufw` admits `22` from Hicks and the tunnel's peers, the tunnel's port, and `8800` from VLAN 30 for the length of a Debian or Kali template build. Applying it on the host is [#1496](https://github.com/Gerrrt/HomeLab/issues/1496). Alloy agent (native package, `scripts/deploy-agent.sh`) | | `golem` (10.0.30.80) | ๐ŸŸข 30 | *(none โ€” an appliance, no Docker)* | Proxmox Backup Server 4.2, built 2026-10-03 by [`build-the-backup-guest.md`](runbooks/build-the-backup-guest.md) ([#485](https://github.com/Gerrrt/HomeLab/issues/485)): the lab's backups, placed by [ADR-0053](adr/0053-run-pbs-on-saruman-with-its-datastore-on-smaug-over-nfs.md). A guest on `Saruman`, VMID 180, whose only datastore, `erebor`, is `smaug`'s `erebor/pbs` over NFSv4 through one `2049` pass, with `atime` on because garbage collection depends on it, and the mountpoint made immutable so an unmounted share cannot fill the OS disk. Every backup is encrypted on `Saruman` before it leaves, with a key made on `Saruman` and copied, on 2026-10-03, into `secrets/lab.sops.yaml` and onto paper (the runbook's ยง7), so a lost `Saruman` does not take the backups' readability with it; `Saruman` writes through a token that can back up and cannot prune. PBS prunes (7 daily, 4 weekly, 3 monthly), collects garbage on Saturdays and verifies on Sundays; TrueNAS keeps fourteen daily snapshots of the dataset as the copy PBS cannot prune. The nightly job takes `odin`, `garuda` and the domain's six, the guests tagged `backup`; `alexander`, `phoenix`, `fenrir` and `golem` itself are rebuilt from this repository and stay out, and so does `eden`, whose graph is one collection run from rebuilt (the runbook's ยง8). `scripts/collect-pbs-task-state.py` publishes every job's last outcome and the snapshots' verify state hourly, and seven rules in `stacks/lab` read them; the first nightly run, 2026-10-03, was verified the next morning. Its Alloy pushes to `alexander`, never to VLAN 99, since 2026-10-03. Alloy agent (native package, `scripts/deploy-agent.sh`) | | `oracle` (10.0.99.30) | ๐Ÿ”ด 99 | [`stacks/wiki`](../stacks/wiki) | The Lemmiwinks wiki and its Postgres, since 2025-11-12 ([ADR-0011](adr/0011-keep-the-wiki-internal.md)), hand-run containers until [#251](https://github.com/Gerrrt/HomeLab/issues/251) wrote them down as a stack deployed by hand from `main`, like `smaug`'s. **Cut over 2026-10-07** ([#847](https://github.com/Gerrrt/HomeLab/issues/847), [ADR-0082](adr/0082-serve-the-wiki-over-tls-and-deploy-it-from-a-verified-checkout.md)): deployed by hand from a checkout whose signature is verified first, and served over https from a Caddy on a leaf from the estate's CA, with port 80 only redirecting ([`stacks/wiki/README.md`](../stacks/wiki/README.md#tls)); its database is pulled to `prometheus` nightly as a `pg_dump` (`make backup-wiki`, [ADR-0065](adr/0065-pull-the-wikis-database-to-prometheus-as-a-dump.md)); Alloy agent (Docker, `scripts/deploy-agent.sh`); the off-host copies of the firewall export (`make backup-firewall`), of the weekly volume sets (`make backup`, [#535](https://github.com/Gerrrt/HomeLab/issues/535)) of the media tier's state pulled off `smaug` (`make backup-nas`, [ADR-0045](adr/0045-pull-jellyfins-state-from-a-snapshot-over-ssh.md)), and of `trinity`'s nightly sensitive-tier volume sets and Immich's library ([ADR-0064](adr/0064-copy-immichs-library-to-oracle-until-the-off-estate-copy-exists.md)). The estate's host for small off-host jobs โ€” [ADR-0015](adr/0015-give-oracle-the-off-host-jobs.md) | -| `trinity` (10.0.99.40) | ๐Ÿ”ด 99 | [`stacks/sensitive`](../stacks/sensitive) | ADR-0008's sensitive tier on the ProDesk 600 G4 of [ADR-0034](adr/0034-run-the-sensitive-tier-on-the-prodesk-and-make-it-the-spare-hardware.md). **Built and deployed 2026-09-28** ([#404](https://github.com/Gerrrt/HomeLab/issues/404), [`build-the-sensitive-tier-host.md`](runbooks/build-the-sensitive-tier-host.md)): Ubuntu 26.04 with both disks LUKS-encrypted and the root unlocked by the TPM ([ADR-0054](adr/0054-encrypt-trinitys-disks-and-seal-the-root-key-to-the-tpm.md)), all twelve containers healthy, and since that day AdGuard is the one forwarder behind `morpheus`'s resolver ([ADR-0055](adr/0055-forward-to-adguard-alone.md)). Holding real data since 2026-09-28, Immich's first 615 photographs, which passed the #404 step 10 gate while most of it was open. The library is copied nightly to `oracle`, off-host and not off-estate, until [#455](https://github.com/Gerrrt/HomeLab/issues/455) ([ADR-0064](adr/0064-copy-immichs-library-to-oracle-until-the-off-estate-copy-exists.md)). The stack: Caddy as the published HTTPS port and step-ca issuing beneath the tier's own root rather than the estate's, which is left untouched ([#129](https://github.com/Gerrrt/HomeLab/issues/129), [#130](https://github.com/Gerrrt/HomeLab/issues/130), [ADR-0037](adr/0037-give-the-sensitive-tier-its-own-root-and-issue-beneath-it-over-acme.md)), with AdGuard Home behind Caddy and publishing 53 to the firewall's forwarder alone ([#135](https://github.com/Gerrrt/HomeLab/issues/135), [ADR-0010](adr/0010-keep-the-resolver-on-the-gateway.md)); Home Assistant ([#134](https://github.com/Gerrrt/HomeLab/issues/134)), Immich โ€” four containers behind Caddy with a memory limit on each ([#132](https://github.com/Gerrrt/HomeLab/issues/132)) โ€” Paperless-ngx with a Postgres and a Valkey of its own ([#133](https://github.com/Gerrrt/HomeLab/issues/133)) and Vaultwarden ([#131](https://github.com/Gerrrt/HomeLab/issues/131)) run beside them, with the household's page of links to them at `home.matrix.elysium` and its live numbers on read-only tokens ([#137](https://github.com/Gerrrt/HomeLab/issues/137)) โ€” Homepage until [ADR-0103](adr/0103-retire-homepage-and-serve-the-household-page-from-glance.md) made it a page of Glance's. ntfy ([#136](https://github.com/Gerrrt/HomeLab/issues/136)) is the in-house receiver for Alertmanager's three real channels, **deployed and cut over 2026-09-29** by [`verify-the-alert-path.md`](runbooks/verify-the-alert-path.md#cutting-over-to-the-in-house-ntfy), with `urgent` and `security` also sent to ntfy.sh for a phone away from home. Miniflux, a feed reader with a Postgres of its own, is the tier's first service beyond ADR-0008's nine, **deployed 2026-09-29** ([#147](https://github.com/Gerrrt/HomeLab/issues/147), [ADR-0057](adr/0057-add-miniflux-to-the-sensitive-tier-with-its-fetcher-kept-off-winterfell.md)): the one container here that reaches outward on a timer, with its fetcher refused every private address. Memos, the household's notes, is the second, decided by [ADR-0059](adr/0059-add-memos-to-the-sensitive-tier-for-notes-and-keep-documentation-in-docs.md) ([#145](https://github.com/Gerrrt/HomeLab/issues/145)) and deployed behind Caddy the same day, all sixteen containers healthy after that `make up`. Miniflux holds no real data; Memos holds the household's first real notes since 2026-10-22, ahead of ADR-0023's off-estate copy by the operator's accepted exception, with the nightly volume set on `oracle` its only copy off the host, since the household copy under [#455](https://github.com/Gerrrt/HomeLab/issues/455) does not carry `memos-data` yet. Mealie, the household's recipes at `recipes.matrix.elysium`, is the third, **deployed 2026-09-29** ([#146](https://github.com/Gerrrt/HomeLab/issues/146), [ADR-0060](adr/0060-add-mealie-to-the-sensitive-tier-as-recipes.md)), behind the same Caddy with no new rule, its URL import refused every private address. linkding, a bookmark manager, is the fourth, **deployed 2026-09-29** ([#144](https://github.com/Gerrrt/HomeLab/issues/144), [ADR-0061](adr/0061-add-linkding-to-the-sensitive-tier-behind-one-factor.md)). Actual ([#142](https://github.com/Gerrrt/HomeLab/issues/142)), the household's budget, is the fifth beyond ADR-0008's nine, **deployed 2026-09-29** ([ADR-0062](adr/0062-add-actual-to-the-sensitive-tier.md)), claimed from SOPS before its first start. It holds no real budget before #404 step 10. Stirling-PDF, the household's PDF editor at `pdf.matrix.elysium`, is the sixth, **deployed 2026-09-29** ([#143](https://github.com/Gerrrt/HomeLab/issues/143), [ADR-0063](adr/0063-add-stirling-pdf-to-the-sensitive-tier-and-keep-its-documents-in-memory.md)): its documents live on a tmpfs and never reach a disk. Glance, the operator's browser start page at `start.matrix.elysium`, is **deployed 2026-10-21** ([#1223](https://github.com/Gerrrt/HomeLab/issues/1223), [ADR-0098](adr/0098-add-glance-as-the-operators-start-page-beside-homepage.md)): the estate's alerts, probes and targets read from `prometheus` with the reader token, and feeds read from a Miniflux user of its own. Since [ADR-0100](adr/0100-grow-glance-into-a-homelab-page-and-keep-the-operators-lists-in-sops.md) it has a page per subject โ€” Home, Read, Watch, Sports & Markets, Homelab, Network & Storage and Maintenance โ€” the estate's read from `prometheus`, and the operator's own lists come from SOPS. It also serves the household's page at `home.matrix.elysium` ([ADR-0103](adr/0103-retire-homepage-and-serve-the-household-page-from-glance.md)), which took over from Homepage. Mosquitto and ring-mqtt bring the Ring Alarm into Home Assistant, the broker on an internal network that only those two join, **deployed 2026-10-22** ([ADR-0104](adr/0104-bring-the-ring-alarm-into-home-assistant-through-ring-mqtt.md)). Alloy agent (Docker, `scripts/deploy-agent.sh`), pushing to `prometheus` like `oracle`'s | +| `trinity` (10.0.99.40) | ๐Ÿ”ด 99 | [`stacks/sensitive`](../stacks/sensitive) | ADR-0008's sensitive tier on the ProDesk 600 G4 of [ADR-0034](adr/0034-run-the-sensitive-tier-on-the-prodesk-and-make-it-the-spare-hardware.md). **Built and deployed 2026-09-28** ([#404](https://github.com/Gerrrt/HomeLab/issues/404), [`build-the-sensitive-tier-host.md`](runbooks/build-the-sensitive-tier-host.md)): Ubuntu 26.04 with both disks LUKS-encrypted and the root unlocked by the TPM ([ADR-0054](adr/0054-encrypt-trinitys-disks-and-seal-the-root-key-to-the-tpm.md)), all twelve containers healthy, and since that day AdGuard is the one forwarder behind `morpheus`'s resolver ([ADR-0055](adr/0055-forward-to-adguard-alone.md)). Holding real data since 2026-09-28, Immich's first 615 photographs, which passed the #404 step 10 gate while most of it was open. The library is copied nightly to `oracle`, off-host and not off-estate, until [#455](https://github.com/Gerrrt/HomeLab/issues/455) ([ADR-0064](adr/0064-copy-immichs-library-to-oracle-until-the-off-estate-copy-exists.md)). The stack: Caddy as the published HTTPS port and step-ca issuing beneath the tier's own root rather than the estate's, which is left untouched ([#129](https://github.com/Gerrrt/HomeLab/issues/129), [#130](https://github.com/Gerrrt/HomeLab/issues/130), [ADR-0037](adr/0037-give-the-sensitive-tier-its-own-root-and-issue-beneath-it-over-acme.md)), with AdGuard Home behind Caddy and publishing 53 to the firewall's forwarder alone ([#135](https://github.com/Gerrrt/HomeLab/issues/135), [ADR-0010](adr/0010-keep-the-resolver-on-the-gateway.md)); Home Assistant ([#134](https://github.com/Gerrrt/HomeLab/issues/134)), Immich โ€” four containers behind Caddy with a memory limit on each ([#132](https://github.com/Gerrrt/HomeLab/issues/132)) โ€” Paperless-ngx with a Postgres and a Valkey of its own ([#133](https://github.com/Gerrrt/HomeLab/issues/133)) and Vaultwarden ([#131](https://github.com/Gerrrt/HomeLab/issues/131)) run beside them, with the household's page of links to them at `home.matrix.elysium` and its live numbers on read-only tokens ([#137](https://github.com/Gerrrt/HomeLab/issues/137)) โ€” Homepage until [ADR-0103](adr/0103-retire-homepage-and-serve-the-household-page-from-glance.md) made it a page of Glance's. ntfy ([#136](https://github.com/Gerrrt/HomeLab/issues/136)) is the in-house receiver for Alertmanager's three real channels, **deployed and cut over 2026-09-29** by [`verify-the-alert-path.md`](runbooks/verify-the-alert-path.md#cutting-over-to-the-in-house-ntfy), with `urgent` and `security` also sent to ntfy.sh for a phone away from home. Miniflux, a feed reader with a Postgres of its own, is the tier's first service beyond ADR-0008's nine, **deployed 2026-09-29** ([#147](https://github.com/Gerrrt/HomeLab/issues/147), [ADR-0057](adr/0057-add-miniflux-to-the-sensitive-tier-with-its-fetcher-kept-off-winterfell.md)): the one container here that reaches outward on a timer, with its fetcher refused every private address. Memos, the household's notes, is the second, decided by [ADR-0059](adr/0059-add-memos-to-the-sensitive-tier-for-notes-and-keep-documentation-in-docs.md) ([#145](https://github.com/Gerrrt/HomeLab/issues/145)) and deployed behind Caddy the same day, all sixteen containers healthy after that `make up`. Miniflux holds no real data; Memos holds the household's first real notes since 2026-10-22, ahead of ADR-0023's off-estate copy by the operator's accepted exception, with the nightly volume set on `oracle` its only copy off the host, since the household copy under [#455](https://github.com/Gerrrt/HomeLab/issues/455) does not carry `memos-data` yet. Mealie, the household's recipes at `recipes.matrix.elysium`, is the third, **deployed 2026-09-29** ([#146](https://github.com/Gerrrt/HomeLab/issues/146), [ADR-0060](adr/0060-add-mealie-to-the-sensitive-tier-as-recipes.md)), behind the same Caddy with no new rule, its URL import refused every private address. linkding, a bookmark manager, is the fourth, **deployed 2026-09-29** ([#144](https://github.com/Gerrrt/HomeLab/issues/144), [ADR-0061](adr/0061-add-linkding-to-the-sensitive-tier-behind-one-factor.md)). Actual ([#142](https://github.com/Gerrrt/HomeLab/issues/142)), the household's budget, is the fifth beyond ADR-0008's nine, **deployed 2026-09-29** ([ADR-0062](adr/0062-add-actual-to-the-sensitive-tier.md)), claimed from SOPS before its first start. It holds no real budget before #404 step 10. Stirling-PDF, the household's PDF editor at `pdf.matrix.elysium`, is the sixth, **deployed 2026-09-29** ([#143](https://github.com/Gerrrt/HomeLab/issues/143), [ADR-0063](adr/0063-add-stirling-pdf-to-the-sensitive-tier-and-keep-its-documents-in-memory.md)): its documents live on a tmpfs and never reach a disk. Glance, the operator's browser start page at `start.matrix.elysium`, is **deployed 2026-10-21** ([#1223](https://github.com/Gerrrt/HomeLab/issues/1223), [ADR-0098](adr/0098-add-glance-as-the-operators-start-page-beside-homepage.md)): the estate's alerts, probes and targets read from `prometheus` with the reader token, and feeds read from a Miniflux user of its own. Since [ADR-0100](adr/0100-grow-glance-into-a-homelab-page-and-keep-the-operators-lists-in-sops.md) it has a page per subject โ€” Home, Read, Watch, Sports & Markets, Homelab, Network & Storage and Maintenance โ€” the estate's read from `prometheus`, and the operator's own lists come from SOPS. It also serves the household's page at `home.matrix.elysium` ([ADR-0103](adr/0103-retire-homepage-and-serve-the-household-page-from-glance.md)), which took over from Homepage. The office wall page, static files under `wall/` that Caddy serves at `wall.matrix.elysium` with eight fixed Prometheus questions behind it, is in the stack since 2026-11-17 for `heimdall`'s kiosk ([ADR-0119](adr/0119-put-the-office-wall-dashboard-on-a-pi-5-on-hicks.md)); the name answers once `morpheus` has its host override. Mosquitto and ring-mqtt bring the Ring Alarm into Home Assistant, the broker on an internal network that only those two join, **deployed 2026-10-22** ([ADR-0104](adr/0104-bring-the-ring-alarm-into-home-assistant-through-ring-mqtt.md)). Alloy agent (Docker, `scripts/deploy-agent.sh`), pushing to `prometheus` like `oracle`'s | | `smaug` (10.0.40.30) | ๐ŸŸก 40 | [`stacks/media`](../stacks/media) | [ADR-0008](adr/0008-place-services-by-data-trust.md)'s media tier on the ThinkServer TS150 of [#413](https://github.com/Gerrrt/HomeLab/issues/413), placed and addressed by [ADR-0016](adr/0016-open-casabonita-inward-and-keep-it-terminal-outward.md) and running TrueNAS rather than Ubuntu Server by [ADR-0040](adr/0040-run-truenas-on-smaug-and-keep-the-media-stack-in-this-repository.md). **Built, pooled and deployed**: TrueNAS on its boot SSD, the static above since 2026-09-16, its inbound rules verified in position (four that day; [`network.md`](network.md#casabonita--vlan-40--media) counts them now), the mirror `erebor` since 2026-09-18 and this stack running on it since 2026-09-19 โ€” from a copy of the compose file on the pool, brought up with `docker compose` under TrueNAS's own Docker ([`build-the-nas.md`](runbooks/build-the-nas.md) ยง6). Jellyfin, publishing 8096 to the segment because the televisions reach it natively and no firewall rule is involved at all ([#138](https://github.com/Gerrrt/HomeLab/issues/138)); and Audiobookshelf on 13378, **deployed 2026-09-29**, whose clients are phones on Hicks and which therefore brought a fifth inbound rule by ADR-0050's count, the seventh to exist ([#140](https://github.com/Gerrrt/HomeLab/issues/140), [ADR-0050](adr/0050-add-audiobookshelf-to-the-media-tier-behind-a-fifth-hicks-pass.md)). And Navidrome on 4533 for music, **deployed 2026-09-30** on the same terms, whose Hicks pass was created 2026-09-22, ahead of the service and of Audiobookshelf's ([#141](https://github.com/Gerrrt/HomeLab/issues/141)). The `media` share gets a Hicks pass on `445` for workstations, used by a second SMB user, `samwise`, so the televisions' `bilbo` stays theirs; it was **created on 2026-09-23** ([#523](https://github.com/Gerrrt/HomeLab/issues/523), [ADR-0051](adr/0051-let-hicks-workstations-mount-the-media-share-as-a-user-of-their-own.md)). Scraped by `prometheus` on `9100`; it pushes nothing, and runs no Alloy โ€” the estate's first scraped host, and the reason [#256](https://github.com/Gerrrt/HomeLab/issues/256) was more than a line of YAML. That issue settled the fork TrueNAS opened in it: `node_exporter`, as a digest-pinned container in this stack rather than TrueNAS's own endpoint, so the existing `99 โ†’ 40:9100` pass, the `host-overview` dashboard and seven rules in `host.rules.yaml` all keep working unchanged. MakeMKV, the disc ripper, is in the file behind the compose profile `rip` and is **not yet deployed**: it reads this host's DVD-RW and writes only into `erebor/media/rips`, runs only while someone is ripping, and is reached from Hicks on `5800` through a pass ยง6.11 creates ([ADR-0114](adr/0114-rip-discs-on-smaug-with-makemkv-started-only-to-rip.md)). The `node` job and `prometheus/targets/node.yaml` are live, and the target with them since 2026-09-19, once the exporter answered from the pool. SMART reaches the same scrape by [ADR-0047](adr/0047-collect-smaug-smart-through-a-root-cron-and-the-textfile-collector.md): a root cron job in TrueNAS's UI runs the estate's collector and the exporter serves the file โ€” still no agent, still nothing initiating from 40 โ€” and patch state is deliberately not collected on an appliance ([#483](https://github.com/Gerrrt/HomeLab/issues/483)) | | `bahamut` (10.0.30.50) | ๐ŸŸข 30 | *(none โ€” Windows)* | Windows Server 2025 domain controller, PDC emulator and DNS for `ad.matrix.elysium` โ€” Tier 0. Static, because every member finds a DC through DNS and the DCs *are* the DNS. Built by hand 2026-09-24 to 2026-09-25 ([#414](https://github.com/Gerrrt/HomeLab/issues/414)) and promoted for `ad.matrix.elysium`. Scraped by `alexander` on `9182`; it pushes nothing, and runs no Alloy ([ADR-0029](adr/0029-size-the-lab-domain-and-separate-its-namespace-and-clock.md)) | | `leviathan` (10.0.30.51) | ๐ŸŸข 30 | *(none โ€” Windows)* | Windows Server 2025 second domain controller and DNS โ€” Tier 0. Static, for the same reason. Built by hand 2026-09-24 to 2026-09-25 ([#414](https://github.com/Gerrrt/HomeLab/issues/414)) and promoted for `ad.matrix.elysium`. Scraped by `alexander` on `9182`; it pushes nothing, and runs no Alloy ([ADR-0029](adr/0029-size-the-lab-domain-and-separate-its-namespace-and-clock.md)) | diff --git a/docs/changelog.md b/docs/changelog.md index 3a833362..447d3952 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -19,6 +19,24 @@ docstring gives: it is a record, not a claim about now. ## 2026-11-17 +- **The office wall page is in the sensitive stack** + ([ADR-0119](adr/0119-put-the-office-wall-dashboard-on-a-pi-5-on-hicks.md)). + `stacks/sensitive/wall/` holds static HTML, CSS and JS in the Tokyo Night + look of the operator's mockup, trimmed from about 18 cards to six panels + and sized for the office television at seven feet. + - **Behind it:** Caddy serves the page at `wall.matrix.elysium` and answers + eight fixed Prometheus questions with the reader token added + server-side. The page picks a name, never a query, and only GET and HEAD + pass. That was checked against the pinned Caddy and a stand-in upstream: + `?query=up` ignored, POST 405 before upstream, `/api/v1/query` 404. + - **When it does not know, it says so:** with Prometheus unreachable or + Watchdog silent it shows that in red instead of "All quiet", and each + source's age is in the status bar. + - **The household half** (calendar, weather, the house) comes through Home + Assistant in a later change. + - **Not live yet:** the name needs a host override on `morpheus`, and the + blackbox probe is committed commented out until it answers. + - **`heimdall`, the office wall dashboard, is on Hicks at `10.0.50.15`** ([ADR-0119](adr/0119-put-the-office-wall-dashboard-on-a-pi-5-on-hicks.md), [`build-heimdall.md`](runbooks/build-heimdall.md)). A Raspberry Pi 5 drives diff --git a/docs/runbooks/build-heimdall.md b/docs/runbooks/build-heimdall.md index f20e56ca..67b7e093 100644 --- a/docs/runbooks/build-heimdall.md +++ b/docs/runbooks/build-heimdall.md @@ -152,8 +152,10 @@ sudo raspi-config nonint do_blanking 1 sudo reboot ``` -The page is Glance's Homelab page until the wall page exists. When it does, -this line's URL is the only change. `--password-store=basic` stops Chromium +The page is the wall page, `https://wall.matrix.elysium/`, once `morpheus` +has its host override (`stacks/sensitive/README.md`, *The wall page*). Until +then the line above shows Glance's Homelab page. Moving between them is this +line's URL and a reboot, nothing else. `--password-store=basic` stops Chromium asking for a keyring at boot, which would otherwise sit on the screen. Blanking off keeps the desktop from turning the screen off. ยง8 turns the television off instead. diff --git a/docs/security.md b/docs/security.md index 9ef2d705..9e0baee1 100644 --- a/docs/security.md +++ b/docs/security.md @@ -1131,6 +1131,17 @@ from Home Assistant with *not enough permissions*. that difference is accepted. It holds two credentials: the reader token, which can only query, and a Fever key that can only mark items read for a Miniflux user that follows public feeds. +- **The wall page answers eight fixed questions** + ([ADR-0119](adr/0119-put-the-office-wall-dashboard-on-a-pi-5-on-hicks.md)): + `wall.matrix.elysium` on `trinity`'s Caddy. Each `/api/q/NAME` is one PromQL + query written in the Caddyfile, sent with the reader token, which Caddy + adds. The caller picks a name, never a query, and its own query string is + discarded. Only GET and HEAD are served, because Prometheus would take a + POST body's `query=` over the URL's. Like Glance it has no login, so + anything that reaches `trinity:443` can read those eight answers: the + firing alerts, per-host CPU, SNMP reachability, WAN traffic and latency, + the UPS and `heimdall`'s temperature. That is less than the Homelab page + already shows, and the page and the Pi hold no credential. - `snmp-exporter` is never published to a host interface โ€” it is reachable only on the compose network. - Alertmanager binds to `127.0.0.1` only. It is unauthenticated, and a silence diff --git a/scripts/check_caddyfile.sh b/scripts/check_caddyfile.sh index 9baeb20c..373b391f 100755 --- a/scripts/check_caddyfile.sh +++ b/scripts/check_caddyfile.sh @@ -83,7 +83,8 @@ for stack in "${STACKS[@]}"; do # a Caddyfile that loads its leaf from files rather than over ACME โ€” the # wiki's (#847) and the ingest proxy's (#764) โ€” since `caddy validate` loads # them and fails on a missing one. It proves the paths and the syntax, not - # the leaf. + # the leaf. It is offered as /etc/caddy/tls/ingest-ca.pem too, the trust pool + # of the sensitive tier's one off-host upstream (the wall page, ADR-0119). openssl req -x509 -newkey rsa:2048 -nodes -days 1 \ -subj '/CN=caddyfile-validation' \ -keyout "${work}/key.pem" -out "${work}/ca.pem" >/dev/null 2>&1 @@ -111,6 +112,7 @@ for stack in "${STACKS[@]}"; do --env-file "${work}/env" \ -v "${work}/Caddyfile:/etc/caddy/Caddyfile:ro" \ -v "${work}/ca.pem:/etc/caddy/tls/ca.pem:ro" \ + -v "${work}/ca.pem:/etc/caddy/tls/ingest-ca.pem:ro" \ -v "${work}/ca.pem:/etc/caddy/tls/cert.pem:ro" \ -v "${work}/key.pem:/etc/caddy/tls/key.pem:ro" \ "${image}") diff --git a/stacks/observability/prometheus/targets/blackbox.yaml b/stacks/observability/prometheus/targets/blackbox.yaml index db62e185..e88b6f54 100644 --- a/stacks/observability/prometheus/targets/blackbox.yaml +++ b/stacks/observability/prometheus/targets/blackbox.yaml @@ -292,6 +292,21 @@ renewal: acme tier: household +# The office wall page (ADR-0119), static files Caddy serves itself, so a +# 200 on `/` proves the site, its certificate and Caddy. COMMENTED OUT until +# morpheus has the `wall` host override (stacks/sensitive/README.md, "The +# wall page", step 5): before that the name does not resolve, and SiteDown +# would fire for a page nobody has been told about yet. +# - targets: ["https://wall.matrix.elysium/"] +# labels: +# module: http_2xx_tier_ca +# name: wall +# role: wall-dashboard +# host: trinity +# via: dns +# renewal: acme +# tier: household + # `/health` answers `{"status":"UP"}` without a session. - targets: ["https://actual.matrix.elysium/health"] labels: diff --git a/stacks/sensitive/Caddyfile b/stacks/sensitive/Caddyfile index 6da53d25..801a7732 100644 --- a/stacks/sensitive/Caddyfile +++ b/stacks/sensitive/Caddyfile @@ -264,6 +264,132 @@ start.matrix.elysium { } } +# The office wall dashboard (ADR-0119): a static page and the Prometheus +# answers it shows, served to `heimdall`'s kiosk and to anything else on a +# segment that reaches 443 here. Two halves, one rule between them: +# +# / the page, from stacks/sensitive/wall/, mounted read-only. +# /api/q/NAME a FIXED question. Each handle below rewrites to one PromQL +# query written in this file, and the reader token is added +# here, server-side. The browser chooses which question, never +# the query: the client's own query string is replaced by the +# rewrite, so /api/q/cpu?query=anything still asks the CPU +# question. Nothing else under /api/ answers. The reader token +# can query and nothing more (ADR-0067); this narrows it again, +# to eight answers. The page holds no credential, and neither +# does the Pi. +# +# The token is the one Glance already holds, GLANCE_PROMETHEUS_TOKEN, given +# to the caddy service in compose.yaml. It is the estate's READER, which +# Glance and Home Assistant already share, so rotating it is still the three +# edits secrets/sensitive.example.yaml lists. The upstream is the ingest proxy +# on `prometheus`, whose leaf the estate CA issued, so that CA is trusted for +# this one transport: the committed stacks/observability/alloy/ingest-ca.pem, +# mounted read-only, the same file render-trust-bundles.sh feeds Glance. +# +# Read-only by method as well: anything but GET or HEAD is refused before a +# handle runs. The CSP lets the page load only itself and fetch only itself, +# so a change to the page that reached for a CDN or a third-party API would +# fail in the browser rather than quietly leak a request. +(wall_prometheus) { + reverse_proxy https://10.0.99.20:9090 { + header_up Authorization "Bearer {$GLANCE_PROMETHEUS_TOKEN}" + header_up -Cookie + header_down -Set-Cookie + transport http { + tls_trust_pool file /etc/caddy/tls/ingest-ca.pem + } + } +} + +wall.matrix.elysium { + header { + Content-Security-Policy "default-src 'none'; script-src 'self'; style-src 'self'; connect-src 'self'; img-src 'self'; font-src 'self'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'" + X-Content-Type-Options nosniff + Referrer-Policy no-referrer + -Server + } + + # `route` keeps the order written: the method gate must run before any + # handle, and Caddy would otherwise sort `respond` after `handle`. It + # matters because Prometheus reads a POST body's `query=` ahead of the + # URL's, so a POST through a rewrite could still ask its own question. + route { + @unsafe not method GET HEAD + respond @unsafe 405 + + # Every firing alert, Watchdog included: its absence means rule evaluation has stopped. + # ALERTS{alertstate="firing"} + handle /api/q/alerts { + rewrite * /api/v1/query?query=ALERTS%7Balertstate%3D%22firing%22%7D + import wall_prometheus + } + + # CPU busy per node_exporter host; a host that stops reporting drops out. + # 100 * (1 - avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m]))) + handle /api/q/cpu { + rewrite * /api/v1/query?query=100%20%2A%20%281%20-%20avg%20by%20%28instance%29%20%28rate%28node_cpu_seconds_total%7Bmode%3D%22idle%22%7D%5B5m%5D%29%29%29 + import wall_prometheus + } + + # Whether each SNMP device answered its last poll: morpheus, mjolnir, neo, shiva. + # max by (device) (up{job="snmp"}) + handle /api/q/snmp { + rewrite * /api/v1/query?query=max%20by%20%28device%29%20%28up%7Bjob%3D%22snmp%22%7D%29 + import wall_prometheus + } + + # WAN traffic now, both directions (rules/internet.rules.yaml). + # homelab_wan_bits_per_second + handle /api/q/wan { + rewrite * /api/v1/query?query=homelab_wan_bits_per_second + import wall_prometheus + } + + # The last hour of download, for the sparkline: a range vector, so a matrix. + # homelab_wan_bits_per_second{direction="receive"}[1h:2m] + handle /api/q/wan_hour { + rewrite * /api/v1/query?query=homelab_wan_bits_per_second%7Bdirection%3D%22receive%22%7D%5B1h%3A2m%5D + import wall_prometheus + } + + # TCP connect time to 1.1.1.1:443, the internet anchor. + # probe_duration_seconds{job="blackbox-latency",name="cloudflare"} + handle /api/q/rtt { + rewrite * /api/v1/query?query=probe_duration_seconds%7Bjob%3D%22blackbox-latency%22%2Cname%3D%22cloudflare%22%7D + import wall_prometheus + } + + # Mjolnir: charge, runtime, time on battery, load. + # {__name__=~"upsEstimatedChargeRemaining|upsEstimatedMinutesRemaining|upsSecondsOnBattery|upsOutputPercentLoad",instance="10.0.99.10"} + handle /api/q/ups { + rewrite * /api/v1/query?query=%7B__name__%3D~%22upsEstimatedChargeRemaining%7CupsEstimatedMinutesRemaining%7CupsSecondsOnBattery%7CupsOutputPercentLoad%22%2Cinstance%3D%2210.0.99.10%22%7D + import wall_prometheus + } + + # Heimdall's own SoC temperature, for the status bar. + # max(node_thermal_zone_temp{instance="heimdall"}) + handle /api/q/pi_temp { + rewrite * /api/v1/query?query=max%28node_thermal_zone_temp%7Binstance%3D%22heimdall%22%7D%29 + import wall_prometheus + } + + handle /api/* { + respond "no such question" 404 + } + + handle { + root * /srv/wall + file_server + } + } + + log { + output stdout + format json + } +} + # The host's own name: nothing is served under it yet. trinity.matrix.elysium { handle { diff --git a/stacks/sensitive/README.md b/stacks/sensitive/README.md index 795b29cc..ed4cfc10 100644 --- a/stacks/sensitive/README.md +++ b/stacks/sensitive/README.md @@ -142,6 +142,8 @@ adguard/AdGuardHome.yaml AdGuard Home's whole configuration, blocklists includ glance/ Glance's configuration: glance.yml and pages/, each mounted read-only, and assets/icons; validated in CI by its own binary +wall/ the office wall dashboard (ADR-0119): static HTML, + CSS and JS, served by Caddy at wall.matrix.elysium ntfy/server.yml ntfy's settings; its users and access list come from SOPS ntfy/templates/ message templates, mounted read-only stirling-pdf/smoke.sh proves the PDF engine works, not just its status endpoint; @@ -738,6 +740,58 @@ is a file under `pages/`, an `$include` line in `glance.yml` and a mount in the tier CA probed it from `trinity` (`probe_success 1`). It is live once `prometheus` pulls the merge; `probe_success{name="glance"}` then reads 1. +## The wall page + +The office wall dashboard, at `https://wall.matrix.elysium`, shown full-screen +by `heimdall`'s kiosk +([ADR-0119](../../docs/adr/0119-put-the-office-wall-dashboard-on-a-pi-5-on-hicks.md), +[`build-heimdall.md`](../../docs/runbooks/build-heimdall.md)). It shows about +eight things at a size read from across the room: the time, the firing +alerts, eight hosts, the internet, the UPS, and how old each answer is. No +container of its own: Caddy serves `wall/` as static files. + +- **The page chooses the question, never the query.** Each `/api/q/NAME` is a + `handle` in the Caddyfile that rewrites to one PromQL query written there, + and Caddy adds the reader token on the way to the ingest proxy on + `prometheus`. A client's own query string is replaced, so + `/api/q/cpu?query=โ€ฆ` still asks the CPU question. Anything else under + `/api/` is 404. Only GET and HEAD reach a handle: Prometheus reads a POST + body's `query=` ahead of the URL's, so the method gate runs first, inside a + `route` that keeps it there. Measured against the pinned Caddy with a + stand-in upstream on 2026-11-17: the question rewritten, `?query=up` + ignored, POST and DELETE 405 without reaching upstream, `/api/v1/query` + 404, the client's cookie stripped and the token added. +- **No credential in the page or on the Pi.** The token is + `GLANCE_PROMETHEUS_TOKEN`, the estate's reader that Glance and Home + Assistant already share, given to the caddy service. Its upstream's leaf + is the estate CA's, so Caddy trusts the committed + `stacks/observability/alloy/ingest-ca.pem` for that one transport. +- **It loads nothing from anywhere else.** The site's Content-Security-Policy + allows only itself. There are no web fonts; the stacks fall back to the + Pi's DejaVu. +- **It says when it does not know.** No answer from Prometheus, or a + Watchdog that is not firing, is shown in red as exactly that, never as + "All quiet". A host that stops reporting reads *no data*. The status bar + gives each source's age and turns amber at two and a half minutes. +- **The household half is not here yet.** The calendar, the weather and the + house come through Home Assistant in a later change, the same way: fixed + entities, a token added by Caddy. +- **Adding it to the running tier.** On `trinity`: + 1. Add `wall` to `trinity`'s *Additional Names for this Host* on `morpheus` + ([`add-a-host-override.md`](../../docs/runbooks/add-a-host-override.md)), + then check that `wall.matrix.elysium` answers `10.0.99.40`. + 2. `make up STACK=sensitive` (or wait for the converge timer). Caddy is + recreated for its alias, its mounts and the site block, and step-ca + issues the name's leaf on the first request. + 3. `curl -s https://wall.matrix.elysium/api/q/alerts | head -c 200` from a + Hicks host that trusts the tier's root: a JSON answer with + `"status":"success"`. + 4. On `heimdall`, change the URL in `~/.config/labwc/autostart` to + `https://wall.matrix.elysium/` and reboot (`build-heimdall.md` ยง7). + 5. Uncomment the `wall` probe in + `stacks/observability/prometheus/targets/blackbox.yaml`, in its own + change, once step 3 answers. + ## ntfy Where the estate's alerts are delivered since [#136], replacing ntfy.sh for diff --git a/stacks/sensitive/compose.yaml b/stacks/sensitive/compose.yaml index 76b3ab08..d34b63c7 100644 --- a/stacks/sensitive/compose.yaml +++ b/stacks/sensitive/compose.yaml @@ -143,6 +143,13 @@ services: - actual.matrix.elysium - pdf.matrix.elysium - start.matrix.elysium + - wall.matrix.elysium + # The reader token, for the wall page's fixed Prometheus questions only + # (the Caddyfile's wall.matrix.elysium block, ADR-0119). It is Glance's + # variable on purpose: one reader, so rotating it stays the three edits + # secrets/sensitive.example.yaml lists. + environment: + GLANCE_PROMETHEUS_TOKEN: ${GLANCE_PROMETHEUS_TOKEN:?set in secrets/sensitive.sops.yaml} mem_limit: 128m memswap_limit: 128m cap_drop: [ALL] @@ -178,6 +185,13 @@ services: # its message says so rather than naming `make certs`, which on this host # would mint a third CA nobody asked for. - ../../certificates/tier-ca.pem:/etc/caddy/tls/ca.pem:ro + # The estate CA, for the one upstream outside this host: the ingest + # proxy on `prometheus`, which the wall page's questions go to. The + # committed copy, the file render-trust-bundles.sh gives Glance, so it + # exists in every checkout and needs no render step. + - ../observability/alloy/ingest-ca.pem:/etc/caddy/tls/ingest-ca.pem:ro + # The wall page itself, static files served as they are (ADR-0119). + - ./wall:/srv/wall:ro ports: - "${BIND_ADDR:-0.0.0.0}:${HTTPS_PORT:-443}:443" depends_on: diff --git a/stacks/sensitive/wall/index.html b/stacks/sensitive/wall/index.html new file mode 100644 index 00000000..74ad0a29 --- /dev/null +++ b/stacks/sensitive/wall/index.html @@ -0,0 +1,79 @@ + + + + + + + + + Elysian Wall + + + + +
+
+ +
+
+
--:--
+
+
+
+ Waiting for Prometheus +
+
+ +
+

Alerts

+
+
+ +
+

Elysian

+
+
+ +
+

Internet

+
+
โ€”
Mb/s down
+
โ€”
Mb/s up
+
โ€”
ms to 1.1.1.1
+
+ +
+ +
+

Power

+
โ€”
+
+
Chargeโ€”
+
Runtimeโ€”
+
Loadโ€”
+
+
+ +
+

Household

+

Today, weather and the house arrive with Home Assistant.

+
+ + +
+
+ + diff --git a/stacks/sensitive/wall/wall.css b/stacks/sensitive/wall/wall.css new file mode 100644 index 00000000..a0fd12a9 --- /dev/null +++ b/stacks/sensitive/wall/wall.css @@ -0,0 +1,227 @@ +/* + * The Elysian Wall (ADR-0119). Tokyo Night colours, sized for a 40" 1080p + * screen read from about seven feet: body text at least 28px, labels at + * least 20px, hero numbers at least 64px. One pixel on that panel is about + * 0.46mm, so 28px is a 13mm line, about 21 arcmin from the desk. + * + * Quiet when healthy: neutral colours, no motion. Colour and the pulse are + * kept for a warning or worse, so a change is what catches the eye. + * + * No web fonts. The CSP allows nothing but this site, and the Pi has DejaVu, + * so the stacks below fall back to it. + */ +:root { + --bg: #1a1b26; + --bg-deep: #16161e; + --panel: #1f2335; + --panel-2: #24283b; + --line: #2b3049; + --fg: #c0caf5; + --fg-dim: #a9b1d6; + --mute: #737aa2; + --blue: #7aa2f7; + --cyan: #7dcfff; + --purple: #bb9af7; + --green: #9ece6a; + --yellow: #e0af68; + --red: #f7768e; + --mono: "JetBrains Mono", "DejaVu Sans Mono", ui-monospace, monospace; + --sans: "Sora", "Inter", "DejaVu Sans", system-ui, sans-serif; + color-scheme: dark; +} + +html, body { + height: 100%; + margin: 0; + background: var(--bg-deep); + color: var(--fg); + font-family: var(--sans); + overflow: hidden; + cursor: none; +} + +#viewport { position: relative; width: 100%; height: 100%; overflow: hidden; } + +#stage { + position: absolute; + left: 50%; + top: 50%; + width: 1920px; + height: 1080px; + box-sizing: border-box; + padding: 36px 44px 24px; + transform-origin: 0 0; + background: var(--bg); + display: grid; + grid-template-columns: 620px 1fr 1fr; + grid-template-rows: 140px 1fr 300px 84px 40px; + grid-template-areas: + "top top top" + "alerts nodes nodes" + "alerts wan power" + "house house house" + "status status status"; + gap: 22px; +} + +/* ---------- header ---------- */ +.top { + grid-area: top; + display: flex; + align-items: center; + justify-content: space-between; + border-bottom: 1px solid var(--line); +} +.clock { + font: 700 120px/1 var(--mono); + letter-spacing: -0.04em; + font-variant-numeric: tabular-nums; +} +.ampm { font: 500 36px/1 var(--mono); color: var(--mute); margin-left: 14px; letter-spacing: 0; } +.date { font: 300 34px/1.2 var(--sans); color: var(--fg-dim); margin-top: 8px; } + +.verdict { + display: flex; + align-items: center; + gap: 18px; + font: 600 40px/1.1 var(--sans); + padding: 18px 30px; + border-radius: 18px; + background: var(--panel); + border: 1px solid var(--line); +} +.verdict .dot { width: 22px; height: 22px; border-radius: 50%; background: var(--mute); flex: none; } +.verdict[data-state="ok"] .dot { background: var(--green); } +.verdict[data-state="warning"] { color: var(--yellow); } +.verdict[data-state="warning"] .dot { background: var(--yellow); } +.verdict[data-state="critical"], .verdict[data-state="broken"] { color: var(--red); } +.verdict[data-state="critical"] .dot, .verdict[data-state="broken"] .dot { background: var(--red); } + +/* ---------- cards ---------- */ +.card { + background: var(--panel); + border: 1px solid var(--line); + border-radius: 18px; + padding: 20px 26px; + min-width: 0; + min-height: 0; + overflow: hidden; + display: flex; + flex-direction: column; +} +.card h2 { + margin: 0 0 14px; + font: 500 22px/1 var(--mono); + letter-spacing: 0.14em; + text-transform: uppercase; + color: var(--mute); +} +.alerts { grid-area: alerts; } +.nodes { grid-area: nodes; } +.wan { grid-area: wan; } +.power { grid-area: power; } +.household { grid-area: house; flex-direction: row; align-items: center; gap: 30px; } +.household h2 { margin: 0; } + +/* ---------- alerts ---------- */ +.alerts-body { display: flex; flex-direction: column; gap: 14px; min-height: 0; } +.quiet { font: 600 56px/1.15 var(--sans); color: var(--fg-dim); margin-top: 20px; } +.quiet small { display: block; font: 400 28px/1.4 var(--sans); color: var(--mute); margin-top: 12px; } +.al { display: flex; gap: 16px; align-items: stretch; } +.al .sev { width: 8px; border-radius: 4px; flex: none; background: var(--blue); } +.al.warning .sev { background: var(--yellow); } +.al.critical .sev { background: var(--red); } +.al .m { font: 600 30px/1.2 var(--sans); min-width: 0; overflow-wrap: anywhere; } +.al .m small { display: block; font: 400 22px/1.3 var(--mono); color: var(--mute); margin-top: 4px; } +.al.critical .m { color: var(--red); } +.more { font: 400 24px/1 var(--mono); color: var(--mute); } +.broken { font: 600 40px/1.2 var(--sans); color: var(--red); } +.broken small { display: block; font: 400 26px/1.4 var(--sans); color: var(--fg-dim); margin-top: 10px; } + +/* ---------- nodes ---------- */ +.node-grid { + flex: 1; + display: grid; + grid-template-columns: repeat(4, minmax(0, 1fr)); + grid-template-rows: repeat(2, minmax(0, 1fr)); + gap: 16px; + min-height: 0; +} +.node { + background: var(--panel-2); + border: 1px solid var(--line); + border-radius: 14px; + padding: 16px 20px; + display: grid; + grid-template-columns: auto 1fr; + grid-template-rows: auto auto 1fr; + column-gap: 14px; + row-gap: 4px; + align-items: center; + min-height: 0; +} +.node .dot { width: 16px; height: 16px; border-radius: 50%; background: var(--green); } +.node .name { font: 600 32px/1.1 var(--mono); overflow: hidden; text-overflow: ellipsis; } +.node .role { grid-column: 1 / 3; font: 400 22px/1.3 var(--sans); color: var(--mute); align-self: start; } +.node .val { grid-column: 1 / 3; align-self: end; font: 500 40px/1 var(--mono); color: var(--fg-dim); font-variant-numeric: tabular-nums; } +.node .val small { font-size: 22px; color: var(--mute); margin-left: 8px; } +.node.warning .dot { background: var(--yellow); color: var(--yellow); } +.node.warning .val { color: var(--yellow); } +.node.down .dot { background: var(--red); color: var(--red); } +.node.down .name, .node.down .val { color: var(--red); } +.node.unknown .dot { background: var(--line); } +.node.unknown .val { color: var(--mute); } + +/* ---------- wan and power ---------- */ +.pair { display: flex; gap: 40px; align-items: flex-end; } +.hero { font: 500 72px/1 var(--mono); color: var(--cyan); font-variant-numeric: tabular-nums; letter-spacing: -0.03em; } +.hero.dim { color: var(--fg-dim); font-size: 64px; } +.unit { font: 400 22px/1.4 var(--sans); color: var(--mute); margin-top: 6px; } +.spark { flex: 1; width: 100%; min-height: 0; margin-top: 14px; } +.spark path.line { fill: none; stroke: var(--green); stroke-width: 2.5; vector-effect: non-scaling-stroke; } +.spark path.fill { fill: var(--green); fill-opacity: 0.12; stroke: none; } + +.power .hero { font-size: 64px; color: var(--fg-dim); } +.power[data-state="battery"] .hero { color: var(--red); } +.kv { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; } +.kv div { display: flex; font: 400 28px/1.2 var(--sans); color: var(--fg-dim); } +.kv b { margin-left: auto; font: 500 30px/1 var(--mono); color: var(--fg); font-variant-numeric: tabular-nums; } + +.placeholder { margin: 0; font: 400 28px/1.3 var(--sans); color: var(--mute); } + +/* ---------- status bar ---------- */ +.status { + grid-area: status; + display: flex; + align-items: center; + gap: 30px; + font: 500 20px/1 var(--mono); + color: var(--mute); + border-top: 1px solid var(--line); + padding-top: 10px; +} +.status .src::before { + content: ""; + display: inline-block; + width: 10px; + height: 10px; + border-radius: 50%; + margin-right: 10px; + background: var(--green); +} +.status .src.stale { color: var(--yellow); } +.status .src.stale::before { background: var(--yellow); } +.status .src.dead { color: var(--red); } +.status .src.dead::before { background: var(--red); } +.status .push { margin-left: auto; } + +/* The only motion: a pulse on what needs looking at. */ +@media (prefers-reduced-motion: no-preference) { + .node.warning .dot, .node.down .dot, .verdict[data-state="critical"] .dot, + .verdict[data-state="broken"] .dot { animation: pulse 1.6s ease-out infinite; } +} +@keyframes pulse { + 0% { box-shadow: 0 0 0 0 currentColor; } + 70% { box-shadow: 0 0 0 14px transparent; } + 100% { box-shadow: 0 0 0 0 transparent; } +} diff --git a/stacks/sensitive/wall/wall.js b/stacks/sensitive/wall/wall.js new file mode 100644 index 00000000..32f87988 --- /dev/null +++ b/stacks/sensitive/wall/wall.js @@ -0,0 +1,291 @@ +// The Elysian Wall (ADR-0119). Every number here is the answer to a fixed +// question at /api/q/NAME, written out in the sensitive tier's Caddyfile. The +// page chooses WHICH question, never the PromQL, and holds no token. +// +// Every value is written with textContent, never innerHTML: label values come +// from Prometheus, and anything that can push a series could otherwise put +// markup on the wall. +"use strict"; + +(() => { + const POLL_MS = 30_000; + // A source with no good answer for this long is shown as stale, and three + // times this as dead, so a frozen number is never mistaken for a live one. + const STALE_MS = 150_000; + // Reload the page now and then, so a change merged to main reaches the wall + // without anyone touching the Pi. + const RELOAD_MS = 6 * 60 * 60 * 1000; + + // The eight tiles, in the order they sit. `cpu` hosts are node_exporter + // hosts, keyed by `instance`; `snmp` devices by the `device` label in + // prometheus/targets/snmp.yaml. + const HOSTS = [ + { name: "morpheus", src: "snmp", role: "firewall" }, + { name: "Saruman", src: "cpu", role: "hypervisor" }, + { name: "trinity", src: "cpu", role: "sensitive tier" }, + { name: "prometheus", src: "cpu", role: "monitoring" }, + { name: "oracle", src: "cpu", role: "wiki, off-host jobs" }, + { name: "smaug", src: "cpu", role: "NAS" }, + { name: "neo", src: "snmp", role: "core switch" }, + { name: "mjolnir", src: "snmp", role: "UPS" }, + ]; + + const QUESTIONS = ["alerts", "cpu", "snmp", "wan", "wan_hour", "rtt", "ups", "pi_temp"]; + const answers = {}; // name -> data.result of the last good answer + const lastOk = {}; // name -> Date.now() of the last good answer + + const $ = (id) => document.getElementById(id); + const el = (tag, cls, text) => { + const e = document.createElement(tag); + if (cls) e.className = cls; + if (text !== undefined) e.textContent = text; + return e; + }; + const num = (r) => Number(r && r.value && r.value[1]); + + // ---------- layout: scale the 1920x1080 stage to the window ---------- + const stage = $("stage"); + function fit() { + const vp = $("viewport"); + const s = Math.min(vp.clientWidth / 1920, vp.clientHeight / 1080); + stage.style.transform = `translate(${-960 * s}px, ${-540 * s}px) scale(${s})`; + } + addEventListener("resize", fit); + fit(); + + // ---------- clock: minutes only, so nothing ticks every second ---------- + const days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; + const months = ["January", "February", "March", "April", "May", "June", "July", + "August", "September", "October", "November", "December"]; + function tick() { + const d = new Date(); + const h = d.getHours(); + $("hm").textContent = `${h % 12 || 12}:${String(d.getMinutes()).padStart(2, "0")}`; + $("ampm").textContent = h < 12 ? "AM" : "PM"; + $("date").textContent = `${days[d.getDay()]}, ${months[d.getMonth()]} ${d.getDate()}`; + } + tick(); + setInterval(tick, 10_000); + + // ---------- fetching ---------- + async function ask(name) { + try { + const res = await fetch(`/api/q/${name}`, { cache: "no-store" }); + if (!res.ok) return; + const body = await res.json(); + if (body.status !== "success") return; + answers[name] = body.data.result; + lastOk[name] = Date.now(); + } catch (_) { + // Network or parse failure: keep the last answer, and let the status + // bar say how old it is. + } + } + + const fresh = (name) => lastOk[name] !== undefined && Date.now() - lastOk[name] < STALE_MS; + + // ---------- alerts and the verdict ---------- + const SEVERITY_RANK = { critical: 0, warning: 1, info: 2 }; + function renderAlerts() { + const body = $("alerts-body"); + const verdict = $("verdict"); + const text = $("verdict-text"); + body.replaceChildren(); + + if (!fresh("alerts")) { + verdict.dataset.state = "broken"; + text.textContent = "No answer from Prometheus"; + const b = el("div", "broken", "Cannot read alerts"); + b.append(el("small", null, "The wall has no recent answer from Prometheus, so nothing here can be trusted.")); + body.append(b); + return; + } + + const all = answers.alerts || []; + const watchdog = all.some((a) => a.metric.alertname === "Watchdog"); + // Without Watchdog firing, rule evaluation has stopped, and "no alerts" + // would mean nothing. Say so instead of looking calm. + if (!watchdog) { + verdict.dataset.state = "broken"; + text.textContent = "Alerting has stopped"; + const b = el("div", "broken", "Watchdog is not firing"); + b.append(el("small", null, "Prometheus answered, but its rules are not being evaluated.")); + body.append(b); + return; + } + + const faults = all + .filter((a) => a.metric.alertname !== "Watchdog") + .sort((a, b) => (SEVERITY_RANK[a.metric.severity] ?? 3) - (SEVERITY_RANK[b.metric.severity] ?? 3)); + + if (faults.length === 0) { + verdict.dataset.state = "ok"; + text.textContent = "All quiet"; + const q = el("div", "quiet", "All quiet"); + q.append(el("small", null, "Nothing is firing.")); + body.append(q); + return; + } + + const worst = faults[0].metric.severity === "critical" ? "critical" : "warning"; + verdict.dataset.state = worst; + text.textContent = `${faults.length} alert${faults.length === 1 ? "" : "s"} firing`; + + const SHOWN = 7; + for (const a of faults.slice(0, SHOWN)) { + const m = a.metric; + const row = el("div", `al ${m.severity || ""}`); + row.append(el("i", "sev")); + const msg = el("div", "m", m.alertname); + const where = m.instance || m.host || m.device || m.name || m.job || ""; + msg.append(el("small", null, [m.severity, where].filter(Boolean).join(" ยท "))); + row.append(msg); + body.append(row); + } + if (faults.length > SHOWN) body.append(el("div", "more", `+${faults.length - SHOWN} more`)); + } + + // ---------- nodes ---------- + function renderNodes() { + const grid = $("nodes"); + grid.replaceChildren(); + const cpu = new Map((answers.cpu || []).map((r) => [r.metric.instance, num(r)])); + const snmp = new Map((answers.snmp || []).map((r) => [r.metric.device, num(r)])); + const charge = (answers.ups || []).find((r) => r.metric.__name__ === "upsEstimatedChargeRemaining"); + + for (const h of HOSTS) { + const tile = el("div", "node"); + const dot = el("i", "dot"); + const name = el("div", "name", h.name); + const role = el("div", "role", h.role); + const val = el("div", "val"); + let state = "ok"; + + if (h.src === "cpu") { + if (!fresh("cpu")) state = "unknown"; + else if (!cpu.has(h.name)) state = "down"; + if (state === "ok") { + const pct = cpu.get(h.name); + val.textContent = `${Math.round(pct)}%`; + val.append(el("small", null, "cpu")); + if (pct >= 90) state = "warning"; + } else { + val.textContent = state === "down" ? "no data" : "โ€”"; + } + } else { + if (!fresh("snmp")) state = "unknown"; + else if (snmp.get(h.name) !== 1) state = "down"; + if (state === "ok" && h.name === "mjolnir" && charge) { + val.textContent = `${Math.round(num(charge))}%`; + val.append(el("small", null, "charge")); + } else { + val.textContent = state === "ok" ? "up" : state === "down" ? "down" : "โ€”"; + } + } + + if (state !== "ok") tile.classList.add(state); + tile.append(dot, name, role, val); + grid.append(tile); + } + } + + // ---------- internet ---------- + const mbps = (bits) => (bits >= 100e6 ? Math.round(bits / 1e6) : (bits / 1e6).toFixed(1)); + function renderWan() { + const wan = answers.wan || []; + const dir = (d) => wan.find((r) => r.metric.direction === d); + const down = dir("receive"); + const up = dir("transmit"); + $("wan-down").textContent = fresh("wan") && down ? mbps(num(down)) : "โ€”"; + $("wan-up").textContent = fresh("wan") && up ? mbps(num(up)) : "โ€”"; + const rtt = (answers.rtt || [])[0]; + $("wan-rtt").textContent = fresh("rtt") && rtt ? Math.round(num(rtt) * 1000) : "โ€”"; + + const svg = $("wan-spark"); + svg.replaceChildren(); + const series = (answers.wan_hour || [])[0]; + if (!fresh("wan_hour") || !series || series.values.length < 2) return; + const ys = series.values.map((v) => Number(v[1])); + const max = Math.max(...ys, 1); + const step = 600 / (ys.length - 1); + const pts = ys.map((y, i) => `${(i * step).toFixed(1)} ${(76 - (y / max) * 70).toFixed(1)}`); + const ns = "http://www.w3.org/2000/svg"; + const fill = document.createElementNS(ns, "path"); + fill.setAttribute("class", "fill"); + fill.setAttribute("d", `M${pts.join(" L")} L600 80 L0 80 Z`); + const line = document.createElementNS(ns, "path"); + line.setAttribute("class", "line"); + line.setAttribute("d", `M${pts.join(" L")}`); + svg.append(fill, line); + } + + // ---------- power ---------- + function renderPower() { + const ups = new Map((answers.ups || []).map((r) => [r.metric.__name__, num(r)])); + const card = document.querySelector(".power"); + if (!fresh("ups") || ups.size === 0) { + card.dataset.state = "unknown"; + $("ups-state").textContent = "โ€”"; + for (const id of ["ups-charge", "ups-runtime", "ups-load"]) $(id).textContent = "โ€”"; + return; + } + const onBattery = (ups.get("upsSecondsOnBattery") || 0) > 0; + card.dataset.state = onBattery ? "battery" : "mains"; + $("ups-state").textContent = onBattery ? "On battery" : "On mains"; + const v = (k, unit) => (ups.has(k) ? `${Math.round(ups.get(k))}${unit}` : "โ€”"); + $("ups-charge").textContent = v("upsEstimatedChargeRemaining", "%"); + $("ups-runtime").textContent = v("upsEstimatedMinutesRemaining", " min"); + $("ups-load").textContent = v("upsOutputPercentLoad", "%"); + } + + // ---------- status bar: how old each answer is ---------- + function age(ms) { + const s = Math.round(ms / 1000); + return s < 90 ? `${s}s` : `${Math.round(s / 60)}m`; + } + function renderStatus() { + const bar = $("status"); + bar.replaceChildren(); + const groups = [ + ["alerts", ["alerts"]], + ["hosts", ["cpu", "snmp"]], + ["internet", ["wan", "wan_hour", "rtt"]], + ["power", ["ups"]], + ]; + for (const [label, names] of groups) { + const oldest = Math.min(...names.map((n) => lastOk[n] ?? 0)); + const span = el("span", "src"); + if (!oldest) { + span.classList.add("dead"); + span.textContent = `${label} ยท never`; + } else { + const ms = Date.now() - oldest; + if (ms >= 3 * STALE_MS) span.classList.add("dead"); + else if (ms >= STALE_MS) span.classList.add("stale"); + span.textContent = `${label} ยท ${age(ms)}`; + } + bar.append(span); + } + const t = (answers.pi_temp || [])[0]; + bar.append(el("span", "push", `heimdall ยท ${fresh("pi_temp") && t ? `${num(t).toFixed(0)}ยฐC` : "โ€”"}`)); + } + + function render() { + renderAlerts(); + renderNodes(); + renderWan(); + renderPower(); + renderStatus(); + } + + async function poll() { + await Promise.all(QUESTIONS.map(ask)); + render(); + } + + render(); + poll(); + setInterval(poll, POLL_MS); + setInterval(renderStatus, 5_000); + setTimeout(() => location.reload(), RELOAD_MS); +})();