tuxvador@blog:~/blog/homelab-dashboard-one-page$

~/blog/homelab-dashboard-one-page

One Page for the Whole Homelab: Building My Own Dashboard

7 min readLire en français →

#security#monitoring#homelab#self-hosting#python

My lab has ten Grafana dashboards, and each one answers its question well. Is the WiFi VPN up? What is CrowdSec banning? Which host carries Critical CVEs? The question none of them answers is the first one I have every morning: is anything wrong, anywhere?

Answering it meant opening Grafana, Uptime Kuma, the Wazuh console, the Proxmox GUI and a terminal for cscli, then putting the picture together in my head. So I built one page that does it for me, with a read-only API behind it so scripts and agents can ask the same question.

What it has to be

  • One verdict at the top: “All systems healthy”, or “3 issues need attention”, with each issue linked to the page that explains it.
  • Every machine: the hypervisor, every container, the dev laptop, the public server and the tailnet.
  • Everything about each one in one place: services, uptime monitors, sites with certificate expiry, alerts, CVEs, logins and the error lines in its logs.
  • Reachable from the internet, because the morning check happens on a phone. So the security model comes first, not last.
  • No new container. It lives on the monitoring container, next to the data it reads.

Two processes, two privilege levels

Most of the useful data needs privileges. Reading the Proxmox API, the Uptime Kuma database, cscli, the Wazuh indexer and Docker on the media server takes SSH keys and passwords. A web process exposed to the internet should hold none of them.

So there are two processes:

browser ──https──> web-proxy (TLS, rate limits) ──https, verified──> mon-srv:8095  web app (user homelab-dash)
                                                                       │ reads Prometheus + Loki on localhost
                                                                       │ reads /var/lib/homelab-dash/snapshot.json
collector.timer (root, every 2 min) ──SSH / APIs──> hypervisor, Kuma DB, cscli, Wazuh, Headscale,
                                                     Docker, Grafana alerts, TLS probes of every site

The collector runs as root every two minutes. It gathers everything that needs a key and writes one JSON snapshot that the web process can read. It reuses a single SSH connection per host (ControlMaster), so it doesn’t add a login line to every host’s auth log every two minutes.

The web app is FastAPI under uvicorn, from Debian packages, running as its own user in a systemd sandbox: ProtectSystem=strict, no capabilities, a syscall filter, and only its state directory writable. It reads Prometheus and Loki on localhost and the snapshot file. It holds no SSH key, no Grafana password and no Wazuh password. If it’s compromised, the attacker gets a read-only view of data they could mostly see on the page anyway.

When a collector section fails (a host is down, an API times out), the page shows that section’s last good data with its age, and the API tab lists what is failing. The timer itself never fails, so an unreachable host produces one clear issue instead of an alert storm.

Problems first

Every tab follows the same rule: what needs attention comes first, and long all-green lists fold their healthy rows behind a toggle. Thirty-two green uptime monitors aren’t information. The one that’s red is.

Tab What it answers
Overview the verdict, the issue list, tiles for infrastructure / security / storage, one card per machine
Machine page everything about one host: history charts, services, sites, alerts, CVEs, logins, error lines from its logs
Services one search across uptime monitors, public sites (status, TLS, expiry), Docker and systemd units
Auth history every login on every machine, failures over time, top failing IPs with their CrowdSec ban status
Security Grafana alerts, Wazuh, CrowdSec scenarios and bans, the cleartext sensor
Storage & backups thin pool, the USB disk, backup runs, SMART data
WiFi & tailnet the access point, its VPN tunnel and clients, the tailnet nodes

Tabs that hold a problem carry a red or orange count badge, so a problem shows up wherever you are on the page.

Some lines are notes rather than issues. Pending security updates on containers are applied by unattended-upgrades the next morning, so they’re grouped into one line, and the verdict stays green.

The security model

The page shows login history, internal addresses and log lines from every machine, and it faces the internet. Every layer below was decided before the first line of UI.

Login is a password plus TOTP. The password is hashed with argon2id. The TOTP code is standard RFC 6238, and a code that was already used can’t be replayed. At first login the QR code is shown once, for enrolment. There’s no signup and no password reset by mail.

The session cookie is __Host-hd_session: Secure, HttpOnly, SameSite=Strict, 256 random bits, stored hashed on the server, 8 hours idle and 24 hours maximum. The __Host- prefix makes the browser refuse it unless it was set over HTTPS, without a Domain, and for path /. Requests that change state also need a custom header and a same-origin Origin.

API tokens are read-only. They allow GET only, are stored as SHA-256, can expire, and can’t create other tokens or see sessions.

Brute force meets four limits:

Layer Limit
nginx 10 requests per minute per IP on the login path
the app an IP locked out after 5 failures in 15 min; everyone after 30
CrowdSec a scenario on the app’s own log: 6 failures, 7-day ban on every bouncer
CrowdSec the slow brute-force rule counts its failures with SSH and mail

Log lines are hostile input. User names and request paths in auth logs are chosen by attackers. A scanner can try to log in as <img src=x onerror=...>. The front end builds the DOM with textContent only, never innerHTML, under a strict Content Security Policy: 'self' only, no inline script or style. Chart SVGs are built with createElementNS.

Secrets in log lines are masked server-side. The machine page shows error lines from each host’s logs, and some reverse-proxy logs carry API tokens in URLs. Values after api_key=, token=, password= and Bearer become *** before they leave the server. The host name in those URLs must be a host Prometheus knows, so nothing else reaches a query.

The network leg is closed too. The backend listens only for the reverse proxy (nftables on the monitoring container), serves TLS from the internal CA, and trusts X-Real-IP only from the proxy’s address.

Making it fast

The slow parts are Loki searches. A cold seven-day auth history across ten log sources took about 20 seconds at first, and opening a machine page ran a search over that host’s logs.

Three changes made it feel instant:

  • A server-side cache with single-flight. Concurrent requests for the same data share one build. Before that, impatient clicking on filters started parallel rebuilds of the same 20-second query, which made each one slower.
  • A warmer thread refreshes the 24-hour login search and every host’s error search shortly before they expire. Nothing a user opens waits on a cold query.
  • Prefetch in the browser. While the tab is visible, it fetches each machine’s data in turn, and again when the pointer hovers over a machine.

The Loki queries for different sources now run in parallel: a cold seven days takes about 8 seconds, a warm machine page about 0.1. One more saving came from looking at the data: the error search had been scanning web access logs, which made one host’s search take 12 seconds. Leaving them out made it take under one, with the same results.

What the first collector run found

The dashboard was useful before it was finished. Its first run listed:

  • An uptime monitor down for 24 hours. The torrent web UI had switched to HTTPS-only, and the monitor still used HTTP.
  • A missing default server on the reverse proxy. A request by bare IP got whichever vhost sorted first, and that had just become the dashboard’s own placeholder, returning 503. A catch-all default_server now answers unknown names with 444.
  • Two container volumes at 98 to 99% allocated. On LVM-thin, deleted files keep their blocks until you trim. pct fstrim freed 24 GiB and took the pool from 70% to 56%.
  • Security updates pending on two hosts, which were applied the same night.

None of those had raised an alert. Each sat in a different tool, and I wasn’t looking at any of them.

Pitfalls

  • Split privilege early. A root collector writing a snapshot plus an unprivileged web process is a small design change on day one and a rewrite later.
  • Reuse SSH connections in collectors. A two-minute timer that opens a fresh SSH session to ten hosts writes 7,000 login lines a day into the logs you’re trying to read.
  • Check the import as the service user before restarting. The first start crash-looped for ten seconds: Debian’s argon2-cffi was older than the code expected. That fired a “systemd unit failed” alert. The install script now imports the app as the service user first and stops if that fails.
  • A strict CSP forbids inline styles too. Set styles through element.style, not style="...".
  • replaceChildren(...nodes) prints null as text. Filter out empty nodes.
  • Preview against real data before deploying. A script snapshots the live API with a one-day token, which it then revokes, and a mock server serves the UI from those fixtures under the same CSP, so every change is screenshotted before it ships.
  • Show “loading”, and draw only the newest result. Without that, a slow query looks like a filter that does nothing.

cd ~/blog