Add Prometheus metrics: /metrics, node_exporter and a page for it

The web UI serves the router's own state at /metrics (token needed);
router.metrics.nodeExporter runs node_exporter for the machine's and opens
its port only to the zones named. The Prometheus page edits those settings
and shows the scrape configuration.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-19 11:30:02 +01:00
co-authored by Claude Sonnet 5.5
parent 32bf0d5fde
commit 6e23d183fc
13 changed files with 672 additions and 1 deletions
+25
View File
@@ -452,6 +452,31 @@ in
'';
};
metrics.nodeExporter = {
enable = mkEnableOption "Prometheus node_exporter: the machine's CPU, memory, disks, network interfaces and systemd units";
port = mkOption {
type = types.port;
default = 9100;
description = "The port node_exporter listens on.";
};
zones = mkOption {
type = types.listOf types.str;
default = [ ];
example = [ "main" ];
description = ''
Zones (a LAN's or tunnel's `zone`, which is the LAN's name unless
set) that may reach node_exporter, with a firewall rule for each. The
port is closed to every other zone and to the internet, so nothing
can scrape it until a zone is named; the router itself can always
reach it on localhost. `wan` is not allowed.
The router's own state (uplink, pings, WireGuard peers, pending
changes, certificate) is at `/metrics` of the web UI instead, which
needs an API token and is reachable wherever the web UI is.
'';
};
};
firewall.zones = mkOption {
type = types.listOf types.str;
default = [ ];