046. Metrics on the mesh addresses

Status: accepted 2026-10-09, built the same day; see docs/metrics.md. Amended 2026-10-25: each mesh's listener shows only that mesh.

Context

The office router reported about a terabyte a day. Nothing could say how much of it was shrooms or which part: tunnels between peers, the delivery node (which a Core node runs for the whole cluster), or something else on the same machines.

Decision

Every daemon serves Prometheus metrics on its own mesh addresses, at metrics_port (default 9180, 0 for off):

The listener binds only overlay addresses, so a member can scrape and the internet cannot. It re-listens every 15 seconds, because meshes come and go.

The scraper finds nodes through the mesh. /targets serves Prometheus' http_sd format, listing the node and its peers. One URL is enough to configure, and nodes that join later are picked up.

Prometheus and Grafana run on one node, from deploy/metrics/install.sh. Grafana stays on loopback and is published as a shrooms service on every mesh the node is on. Anonymous viewing is on: the mesh is the boundary (ADR-041).

Settled with it: the services endpoint now writes to the mesh it is told, and a node on several meshes without a top-level one refuses a write that names no mesh. Before, such a write went to the top-level services list, which belongs to no mesh there. It was accepted, read back correctly, and never published. That is how Grafana on the VPS first stayed invisible.

Consequences

Amendment, 2026-10-25: each mesh sees only itself

As built, every listener served one page for all of a node's meshes, and /targets listed every mesh's machines. A member of one mesh could read the names, overlay addresses and traffic of every other mesh the node was on. That undid what per-mesh identities are for (ADR-015): joining a shared mesh is meant to reveal nothing about a private one. Found on 2026-10-25, while checking shrooms against a report on Tailscale's serve and SSH. That report's finding 11 is the same class: one mount's context reached another's.

A mesh's listener now serves that mesh.

Since a machine on two meshes is now two targets, /targets marks one per machine first="1". Prometheus keeps the machine's own series and its agent from that target only, so dashboards that sum by node are unchanged.

What a member can still learn is about the machine, not the other meshes: its load, memory and physical interfaces' traffic. Correlating those figures across two meshes could suggest that two devices are one machine. That is weaker than reading the other mesh's roster, which is what was fixed.