Swarm telemetry: metrics, logs and the collector

How the swarm's metrics store, Grafana, log store and OTEL collector connect, and who may reach each. The operator's overview, with the options to touch and how to open each service, is on the services page.

Metrics (VictoriaMetrics + Grafana)

The swarm's telemetry lands in one VictoriaMetrics, and one Grafana reads it, in two containers at metrics.<swarm-domain> and grafana.<swarm-domain>. Two containers rather than one so you can restart or break Grafana without taking the time-series database with it.

The Grafana container sits on the hive bridge in a network namespace of its own and dials authelia, the secret store, the collector and both datasources by name through it. It binds no TCP port: it listens on the unix socket /run/swarm-grafana/grafana.sock, a directory only the gateway's nginx and the container can open.

They derive together: a store with no UI is unreadable and a UI with no store is empty. To run one without the other, set it directly:

services.hyperhive.deploy = {
  victoriametrics.enable = true;
  grafana.enable = false;
};

⚠️ This starts a database that grows for as long as the swarm runs. See retentionPeriod below before leaving it at its default.

Option When you'd touch it
deploy.victoriametrics.retentionPeriod Default 5y. Lower it once you have measured how fast this swarm actually fills a disk — the default is deliberately generous because too-short silently discards history you can't get back.
swarm.grafana.oidc.role Default Admin for everyone who logs in. Lower to Viewer/Editor if the swarm grows operators who shouldn't be able to reconfigure Grafana.
deploy.grafana.datasourceUrl Only if you front VictoriaMetrics with something else. It defaults to the store's swarm name (https://<swarm.victoriametrics.domain>), so Grafana and the store can run on different hosts.
deploy.grafana.logsDatasourceUrl Only if you front VictoriaLogs with something else. It defaults to the log store's swarm name (https://<swarm.victorialogs.domain>), so Grafana and the store can run on different hosts.
deploy.victoriametrics.agentAuthRate Default 50r/s per client address, for agent reads checked by swarm-metrics-agent-auth; over it and agentAuthBurst, the gateway answers 403.
deploy.victoriametrics.agentAuthBurst Default 500 requests above agentAuthRate before the 403s start.
deploy.victoriametrics.agentAuthVerdictTtl Default 60 seconds that swarm-metrics-agent-auth keeps granting an agent secret it verified. A replaced or deleted secret keeps working at the metrics store for up to that long. A revoked metrics permission does too.
deploy.victoriametrics.agentAuthPackage The swarm-logs-auth build that runs as swarm-metrics-agent-auth. Set on its own: deploy.victorialogs.authPackage doesn't reach it.

Logging in. Grafana is behind swarm SSO, so the accounts are the authelia ones, and the local login form is always off. Grafana's API still accepts HTTP basic auth for its built-in admin account, so that account's password is a random one minted into the swarm secret store (swarm/services/<grafana client id>/admin/password) and applied on every Grafana start — see credentials.md.

Dashboards. Grafana provisions these from nix/host-modules/swarm-grafana/dashboards/; edits made in the UI aren't kept.

A new panel can read "No data" until its source exists: the push and commit counters on controller appear after the first push webhook, the refused and failure series on collector appear once something fails, and the review-classifier panels fill as review requests arrive.

The collector dashboard. It shows the self-metrics of the hive's collector and of the swarm's collector, which both carry the collector binary's default service.name, otelcol-contrib. The timeseries panels split by server.port: 8888 is the hive collector, 8889 the swarm collector. Every per-container collector (the secret store, the other service containers and the agents' forwarders) also scrapes its own endpoint on loopback and pushes the result up its normal hop, so each has a line of its own, on its own port: agents all report on 8904, service containers on 8890 to 8903. The series carry container (services) or agent (agents) to tell them apart. scripts/check-dashboard-service-names.sh runs in CI and in scripts/pre-push. It fails when a dashboard query selects a service.name that nothing emits.

Where the data comes from. The swarm's OTEL collector, below.

The controller panels come from the controller itself. It exports OTLP through the gateway to the swarm's collector from whatever host it runs on, whether or not that host runs the collector.

Neither container is reachable except through the gateway: each listens on a unix socket only the gateway's nginx can open, and VictoriaMetrics runs in a network namespace of its own with no interface but loopback. VictoriaMetrics authenticates nothing itself; the metrics.<swarm-domain> vhost does it:

The gateway remembers authelia's answer for the collector's push route. It keys the answer on the request's Authorization header and the route, keeps only a 200, and keeps it for 60 seconds. A burst of pushes from one token costs authelia one subrequest, and a push that finds its verdict in the cache doesn't wait on authelia, however slow it is. A 401 or 403 always goes to authelia again. A request without an Authorization header skips the cache, and the subrequest drops the Cookie header. A revoked or expired token keeps pushing for up to 60 seconds. The /metrics scrape and the other routes ask authelia every time.

swarm-metrics-auth and swarm-metrics-agent-auth read the store with one leaf, deploy.victoriametrics.authBaoClientCertFile / authBaoClientKeyFile. Where the secret store runs on the same host, these default to the leaf it mints. On any other host you place a leaf whose CN is deploy.bao.metricsAuthCommonName, and evaluation refuses the config until you set both. swarm-metrics-auth reads the stored bearer at most once a minute, so a replaced bearer starts working up to a minute later. When the store doesn't answer within five seconds, it checks requests against the last value it read instead of denying, and still refuses a wrong bearer; it tries the store again after three seconds. A revoked or rotated bearer stays accepted while the store is down, for an hour after the last read at most; after that the responder denies again. The store's next answer replaces the value, and a process that holds none (it started while the store was down) denies. swarm-logs-grafana-auth is the same binary and does the same.

swarm-metrics-agent-auth is the log store's swarm-logs-auth binary, with the same grant TTL and rate limit, under deploy.victoriametrics.agentAuth* (table above).

The store's container has no network, so its journal forwarder leaves through a relay. Inside the container, swarm-victoriametrics-egress-relay listens on loopback and passes each connection to a socket the host's nginx listens on, /run/swarm-victoriametrics-egress/egress.sock. nginx sends the forwarder's route to the swarm collector and its token request to authelia, both by name and verified, and refuses every other path. On the host, swarm-victoriametrics-forwarder-oidc.service fetches the forwarder's OIDC secret under the same leaf as swarm-metrics-auth, and the container sees it read-only through a bind mount.

The collector scrapes Grafana's own metrics at https://<swarm.grafana.domain>/metrics, so a collector on a host without Grafana still gets them. The gateway admits only the collector's client to that path; any other session gets deny.

The collector scrapes the store's own metrics the same way, at https://<swarm.victoriametrics.domain>/metrics, so a collector on a host that doesn't run the store still gets them. On this name the gateway admits only the collector's client to /metrics and the push route; any other session gets deny.

Logs (VictoriaLogs)

Each hive ships its journals to one VictoriaLogs at logs.<swarm-domain>, behind the same SSO as everything else: the swarm's own service containers, the hive's daemons and infra containers, and the harness units inside every agent container. The collector below is what writes to it.

Reading them. Open Grafana, pick Explore, and choose the VictoriaLogs datasource — it's provisioned for you. Grafana's Logs Drilldown app is deliberately not installed: it only supports Loki, and no setting here changes that, so Explore is the log browser for this swarm.

Option When you'd touch it
deploy.victorialogs.retentionPeriod Default 30d, far shorter than the metrics store's — logs are bulkier per unit of value and are typically read within days of ingestion. Raise it if you need to answer questions about last quarter.
deploy.victorialogs.authRate Default 50r/s per client address, for agent queries checked by swarm-logs-auth; over it and authBurst, the gateway answers 403. Agents on one host share the address; the default covers about a hundred cold-starting together.
deploy.victorialogs.authBurst Default 500 requests above authRate before the 403s start.
deploy.victorialogs.authVerdictTtl Default 60 seconds that swarm-logs-auth keeps granting an agent secret it verified, without asking the secret store. A replaced or deleted secret keeps working at the log store for up to that long. A revoked logs permission does too.
deploy.victorialogs.grafanaAuthPackage The swarm-metrics-auth build that runs as swarm-logs-grafana-auth. Set on its own: deploy.victoriametrics.authPackage doesn't reach it.
swarm.victorialogs.domain Only to rename it.

It listens on a unix socket in a network namespace of its own, on the hive bridge so its journal forwarder can reach the swarm collector, and binds no host port. Only the gateway's nginx can open the socket. It takes no credential of its own: the gateway vhost is the only way in, and the collector is the only intended writer.

Who may query. /select/logsql/ takes one of three credentials. An agent presents its swarm-agent.<agent>.<secret> bearer, checked by swarm-logs-auth. The agent must also hold the logs permission, which is off by default; without it the answer is a 403 (docs/5-project/process/conventions.md, Permissions). Grafana's datasource presents the same bearer as its metrics datasource, which swarm-bao-grafana-metrics-bearer creates, and a second swarm-metrics-auth instance (swarm-logs-grafana-auth) on the log store's host checks it against the same store path; the gateway tells it from the others by its shape, 64 hex digits. Anything else needs an operator's authelia session. Because one bearer opens both read APIs, a rotation (see credentials.md) restarts Grafana once, and the log store accepts the new value within a minute.

The collector also scrapes this store's own metrics, at https://<swarm.victorialogs.domain>/metrics, so a collector on a host without the store still gets them. On this name the gateway admits only the collector's client to /metrics and the ingest route /insert/opentelemetry/v1/logs; any other session gets deny on both. The read side stays open to any authenticated caller.

The log store's ingest route /insert/opentelemetry/v1/logs gets the same 60-second cache of authelia's 200 answers as the metrics store's push route, with the same revocation window. The log store's other routes ask authelia every time.

Telemetry collector (OTEL)

The swarm's collector receives from every hive's own collector and is the only process that decides where telemetry goes: it always writes the stores above, and exports to deploy.swarm-otel.upstream.endpoint as well when that's set. Which signals go there is deploy.swarm-otel.upstream.signals (default [ "metrics" "logs" ]); the stores always get both. It holds the upstream credential, which is why no hive and no agent needs one.

It runs in a swarm-otel container on the hive bridge, in a network namespace of its own. It binds no OTLP port: every receiver (one per hive, the swarm tier's and one per service forwarder) listens on a unix socket in /run/swarm-otel, a directory only the gateway's nginx and the container can open, and the gateway forwards to them. The gateway's routes and the collector's receivers come from one list, so they name the same sockets. The swarm-otel-sockets unit connects to each socket as the gateway's user after the container starts, then requests every route through the gateway vhost. It fails if a socket refuses for 30 seconds, or if a route answers 000, 502 or 504, or lacks its own X-Swarm-Otel-Route response header, for 30 seconds. The gateway sets that header, named after the route, on every response from a route, so a collector that's up but not listening, or an nginx that doesn't have the route, shows as a failed unit. Any status other than those passes, the collector's 4xx included. A switch leaves a window of about 20 seconds in which nginx and the container are out of step: the container stops before nginx restarts and starts about 18 seconds after it. Senders retry through that window.

What the collector stamps. Every authenticated receiver feeds one metrics pipeline and one logs pipeline. Their first processor, resource/sender, deletes any sender and hive attribute the payload carried on the resource, then sets sender from the token's client_id claim and swarm to the swarm's display name. sender is therefore the client that authenticated: hive-<name> for a hive's collector, the service's own client for a service forwarder. A token without the claim leaves the record with no sender. The collector stamps no hive label. A hive is a place an agent runs: dashboards and alerts select an agent by agent and a machine by host.name, and the alert no log records from <hive> selects on sender. Records that nothing authenticated (the host's journal, the collector's own journal and the Prometheus scrapes) carry swarm and no sender. A batch processor must never run before resource/sender, because a batch drops the authentication context. A second processor, attributes/sender, deletes sender and hive from every datapoint and log record, where a sender can set them too. Scope attributes stay as sent.

The collector fetches authelia's discovery document through the gateway when it starts and exits if that fails. systemd restarts it with no start limit and a delay that grows from 2 to 60 seconds, so it comes back by itself once the gateway and authelia answer. If ingest stops, systemctl status swarm-otel-sockets on the host shows whether the receiver sockets are there; machinectl shell swarm-otel /run/current-system/sw/bin/journalctl -u opentelemetry-collector shows why the collector didn't start. A collector that keeps retrying never reaches failed, so systemctl --failed doesn't list it. The signals are swarm-otel-sockets failing and the Grafana alert no log records from <hive>, which fires after about 15 minutes without a log record stamped with that hive's sender.

Every hive's own collector reaches this one by its gateway name, swarm.otel.domain (default otel.<swarm domain>) — the same by-domain-through-the-gateway shape every other swarm service uses, not a loopback URL an operator has to redirect. Nothing needs setting on a hive that doesn't run the swarm's services; the name resolves through the gateway either way.

Option When you'd touch it
swarm.otel.domain Only to rename it — the default already resolves correctly for every hive in the swarm.

The swarm-bao, swarm-nats, swarm-builder, swarm-claude-login, swarm-notify-router, swarm-review-classifier, swarm-ci-runner, swarm-grafana, swarm-victorialogs, swarm-victoriametrics, swarm-authelia, swarm-attic, hive-forge and hive-matrix containers each run a collector of their own that forwards the container's journal here, on a route and receiver per service (https://<swarm.otel.domain>/<container>/), authenticated as an OIDC client of that service's. The queue, builder, login minter, notification router and classifier reuse the service's own client; the store, CI runner, Grafana, log store, metrics store, authelia, cache, forge and homeserver have a forwarder client of their own (swarm.<service>.otel.clientId). Their records carry service.name (bao, nats, builder, claude-login, notify-router, review-classifier, ci-runner, grafana, victorialogs, victoriametrics, authelia, attic, forgejo, tuwunel) and the sender of its own client id. The forwarder of all but the store's is nix/container-modules/swarm-journal-forwarder.nix.

The homeserver's metrics. tuwunel 1.9.4 exports no metrics of its own, so request rates, sync load and federation traffic aren't available. Two series stand in for them, and neither adds a service:

The swarm collector's own container, swarm-otel, has no forwarder: its collector reads the container's journal itself (receiver journald/self) and exports it to the log store like the host's journal, stamped service.name swarm-otel and with no sender, since nothing authenticated it. Unlike the host's journal, it goes to the log store only, never the upstream: the collector writes an upstream export failure to this journal, and shipping it upstream would fail again. A filter processor also drops the collector's own failure lines that name the store exporter (otlphttp/victorialogs), which can't reach the store anyway; failures of every other exporter still arrive. The container mounts the host's journal read-only at /run/host-journal, not over its own /var/log/journal.

Every collector that reads a journal drops its own export failures before it exports: the hive collector, the agent and service-container forwarders, and the swarm collector's host-journal pipeline. A filter processor (nix/collector-own-export-failures.nix) matches records from the unit opentelemetry-collector.service whose message contains Exporting failed or sending queue is full. Without it, an ingest outage makes each collector log one line per failed batch, its receiver reads the line back and pushes it, and the pushes add to the outage. The collector's startup, configuration and receiver errors still ship. The failure itself stays visible in the collector's otelcol_exporter_send_failed_* metrics.

Both store exporters are unconditional, and deploy.victoriametrics.enable doesn't gate them: that option says this host runs the store, while the swarm has one either way, reached by its swarm name through the gateway.

Agent-side configuration, and what a hive's own collector does, are in scheduler/observability.md.