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
+4 -1
View File
@@ -270,7 +270,7 @@ func newApp(sys System, metrics *Collector, dev bool) *app {
func (a *app) parseTemplates() (map[string]*template.Template, error) {
files := map[string][]string{"overview": {"templates/dashboard.html"}}
pages := map[string]*template.Template{}
for _, page := range []string{"login", "overview", "network", "dhcp", "dns", "wireguard", "firewall", "ddns", "dnsproviders", "certificate", "advanced", "update", "upgrade", "tokens", "changes"} {
for _, page := range []string{"login", "overview", "network", "dhcp", "dns", "wireguard", "firewall", "ddns", "dnsproviders", "certificate", "exporter", "advanced", "update", "upgrade", "tokens", "changes"} {
t, err := template.New("layout.html").Funcs(a.funcs).
ParseFS(assets, append([]string{"templates/layout.html", "templates/" + page + ".html"}, files[page]...)...)
if err != nil {
@@ -328,6 +328,8 @@ func (a *app) routes() http.Handler {
mux.HandleFunc("POST /dnsproviders", a.auth(a.providersSave))
mux.HandleFunc("GET /certificate", a.auth(a.certificatePage))
mux.HandleFunc("POST /certificate", a.auth(a.certificateSave))
mux.HandleFunc("GET /prometheus", a.auth(a.exporterPage))
mux.HandleFunc("POST /prometheus", a.auth(a.exporterSave))
mux.HandleFunc("GET /firewall", a.auth(a.firewallPage))
mux.HandleFunc("POST /firewall", a.auth(a.firewall))
mux.HandleFunc("GET /dhcp", a.auth(a.dhcpPage))
@@ -344,6 +346,7 @@ func (a *app) routes() http.Handler {
mux.HandleFunc("POST /upgrade/channel", a.auth(a.upgradeChannel))
mux.HandleFunc("POST /upgrade/{step}", a.auth(a.upgradeStep))
mux.HandleFunc("/mcp", a.mcp)
mux.HandleFunc("GET /metrics", a.promMetrics)
a.registerAPI(mux)
mux.HandleFunc("GET /tokens", a.auth(a.tokensPage))
mux.HandleFunc("GET /apireference", a.auth(a.apiReference))