Monitoring¶
The leader answers three questions for machines: is the process alive
(/api/v1/health), can it take traffic (/api/v1/ready), and what is it doing
(/api/v1/metrics, Prometheus text). Fellows have no endpoint of their own:
they dial out and are often behind NAT, so their numbers reach Prometheus
through the leader. People read the same numbers on the admin page
System and the pool
dashboards.
Probes¶
| Component | Probe | Endpoint / command | What it checks |
|---|---|---|---|
| Leader | startup + liveness | GET /api/v1/health (public) |
The process answers: always 200 with status: "ok". The leader is one replica, so a failed liveness probe would mean a restart and downtime. The body has loops: {name: {age_s, stale}}, version, source_sha, extensions and public_url. |
| Leader | readiness | GET /api/v1/ready (public) |
503 with reasons while starting or stopping, when the state DB takes no real write, below SWARM_MIN_FREE_DISK_GB free, or when the sweep (dispatch, timeouts, recovery) or the metrics roll-up has not finished a tick for max(SWARM_LOOP_STALE_S, 5 x its interval). A loop's age counts from its start, so a starting leader is never stale before its loops could tick. Also registered_workers and ready_workers. Fellows do not count: a leader without fellows still takes traffic. |
| Headscale sidecar | readiness + liveness | GET /health on port mesh (8081) |
Headscale's own check. |
| Frontend (nginx) | readiness + liveness | GET /healthz |
nginx answers. Static, so it passes without the docs build and without the leader. |
| Fellow | startup + liveness | exec python -m silent_swarm.fellow.health_check |
The runner touches <control dir>/alive every 10 s; fails when the file is older than SWARM_FELLOW_ALIVE_MAX_S (60). It never asks the leader, so a leader restart never restarts fellows. |
| Variable | Default | Meaning |
|---|---|---|
SWARM_LOOP_STALE_S |
300 |
The least silence of a critical loop that fails readiness; a slow loop gets 5 x its interval. 0 switches the check off (the loops still show). |
SWARM_MIN_FREE_DISK_GB |
2 |
Free space the state volume keeps; below it the leader is not ready and refuses uploads. |
The mail worker and the control pings are watched too, shown on the System page
and in swarm_background_loop_last_tick_age_seconds, but never fail readiness:
an SMTP server being slow is no reason to stop serving.
Scraping /api/v1/metrics¶
The endpoint needs an operator credential: a session, or an API token with the
read scope (Profile, API tokens). What a scrape shows depends on whose
credential it is:
- an admin's token, or a scraper token no user owns, sees every pool and the
leader-wide series (build, readiness, loops, storage,
process_*, HTTP, registrations, relay); - a member's token sees the series of their own pools and nothing leader-wide.
curl -s -H "Authorization: Bearer $SWARM_TOKEN" https://leader.example.com/api/v1/metrics
# prometheus.yml
scrape_configs:
- job_name: silentswarm
scheme: https
metrics_path: /api/v1/metrics
authorization:
credentials_file: /etc/prometheus/swarm-token
static_configs:
- targets: [leader.example.com]
In Kubernetes, metrics.serviceMonitor.* in the Helm chart
does this with the token from a Secret.
Counters and histograms live in the leader's memory and start at zero with the
process; rate() and increase() handle the reset. A series with nothing to
report is left out rather than reported as 0. Labels are bounded: pools by
slug, nodes by fellow_id, GPUs by index, HTTP by route template - never a raw
path or a host name.
Metric reference¶
Cluster (every caller, scoped to their pools)¶
| Metric | Type | Labels | Meaning |
|---|---|---|---|
swarm_registered_workers |
gauge | - | registered fellows |
swarm_workers_ready / swarm_workers_failed |
gauge | - | fellows by status |
swarm_active_job |
gauge | - | jobs pending, running or recovering |
swarm_ws_connections |
gauge | - | open signal WebSockets |
swarm_worker_last_step |
gauge | fellow_id |
last training step a worker reported |
Pools, nodes and GPUs (scoped)¶
| Metric | Type | Labels | Meaning |
|---|---|---|---|
swarm_pool_tokens_out_per_s |
gauge | pool |
completion tokens/s over the last 5 minutes |
swarm_pool_error_rate |
gauge | pool |
failed generations / total, last 5 minutes |
swarm_pool_ttft_ms_p95 |
gauge | pool |
p95 time to first token the leader computed (kept for compatibility; prefer swarm_ttft_seconds) |
swarm_pool_nodes_online |
gauge | pool |
online nodes |
swarm_inflight_requests |
gauge | pool |
open generations, queued ones included |
swarm_queued_requests |
gauge | pool |
generations waiting for a fellow to pick them up |
swarm_node_grade_score |
gauge | pool, fellow_id |
node health score 0-100 |
swarm_node_availability_pct |
gauge | pool, fellow_id |
heartbeats received / expected |
swarm_node_heartbeat_age_seconds |
gauge | pool, fellow_id |
seconds since the last heartbeat |
swarm_gpu_vram_used_bytes / swarm_gpu_vram_total_bytes |
gauge | pool, fellow_id, gpu |
GPU memory, online nodes only |
swarm_gpu_utilization_ratio |
gauge | pool, fellow_id, gpu |
utilisation 0-1 |
swarm_gpu_power_watts |
gauge | pool, fellow_id, gpu |
board power (absent for cards that do not report it) |
swarm_gpu_temperature_celsius |
gauge | pool, fellow_id, gpu |
temperature |
Serving (scoped)¶
| Metric | Type | Labels | Meaning |
|---|---|---|---|
swarm_generations_total |
counter | pool, outcome |
finished generations: ok, error, timeout, client_gone, model_not_loaded, too_long, refused |
swarm_tokens_out_total |
counter | pool |
completion tokens of successful generations |
swarm_tokens_in_total |
counter | pool |
prompt tokens |
swarm_ttft_seconds |
histogram | pool |
request to first token |
swarm_generation_duration_seconds |
histogram | pool |
request to last frame |
A request refused before it reached a fellow (model_not_loaded) belongs to no
pool: pool="", seen only by an unscoped scrape.
Training and recovery (scoped)¶
| Metric | Type | Labels | Meaning |
|---|---|---|---|
swarm_job_step |
gauge | job_id, pool |
latest step of an active job |
swarm_job_loss |
gauge | job_id, pool |
latest loss |
swarm_job_tokens_per_s |
gauge | job_id, pool |
steps/s over the last 10 minutes x batch_size x seq_len |
swarm_incidents_opened_total |
counter | pool, kind |
recovery incidents opened (train, serve) |
swarm_incidents_total |
counter | pool, kind, outcome |
incidents closed, by outcome |
The leader (admins and unowned scraper tokens only)¶
| Metric | Type | Labels | Meaning |
|---|---|---|---|
swarm_build_info |
gauge | version, source_sha |
always 1 |
swarm_leader_start_time_seconds |
gauge | - | Unix time the leader started |
swarm_leader_ready |
gauge | - | 1 when /api/v1/ready answers 200 |
swarm_background_loop_last_tick_age_seconds |
gauge | loop |
sweep, rollup, control_ping, mail |
swarm_event_loop_lag_seconds |
gauge | - | how late the event loop woke from its last 1 s sleep |
swarm_state_db_bytes |
gauge | - | the state DB on disk, WAL included |
swarm_state_disk_free_bytes / swarm_state_disk_floor_bytes |
gauge | - | free space on the state volume, and SWARM_MIN_FREE_DISK_GB |
process_cpu_seconds_total |
counter | - | CPU time |
process_resident_memory_bytes, process_virtual_memory_bytes, process_open_fds, process_max_fds, process_start_time_seconds |
gauge | - | the standard process numbers (memory and fds on Linux) |
swarm_http_requests_total |
counter | method, route, status |
requests by route template; unmatched for none |
swarm_http_request_duration_seconds |
histogram | method, route |
duration; a stream or long-poll counts to its last byte |
swarm_node_registrations_total |
counter | result |
accepted, probation, quarantined, refused |
swarm_relay_bytes_total |
counter | direction |
bytes through the relay: in pushed, out popped |
Recommended alerts¶
The Helm chart ships these as a PrometheusRule, off by default
(metrics.prometheusRule.enabled). They read leader-wide series, so the
ServiceMonitor's token must be an admin's or an unowned scraper token.
# Leader not ready, for 5m
swarm_leader_ready == 0
# No ready fellows, for 10m (readiness ignores fellows on purpose)
swarm_workers_ready == 0
# A critical background loop has stopped, for 2m (readiness fails on the same)
swarm_background_loop_last_tick_age_seconds{loop=~"sweep|rollup"} > 300
# The state volume is close to its floor, for 10m
swarm_state_disk_free_bytes < swarm_state_disk_floor_bytes * 1.5
# A fellow has gone silent, for 5m
swarm_node_heartbeat_age_seconds > 120
# More than 10 % of a pool's generations fail, for 10m
sum by (pool) (rate(swarm_generations_total{outcome=~"error|timeout|client_gone|model_not_loaded"}[10m]))
/ sum by (pool) (rate(swarm_generations_total[10m])) > 0.1
The thresholds are values of the chart: loopStaleSeconds, heartbeatAgeSeconds, errorRatio.
Useful queries:
# p50 and p95 time to first token per pool, over 5 minutes
histogram_quantile(0.5, sum by (pool, le) (rate(swarm_ttft_seconds_bucket[5m])))
histogram_quantile(0.95, sum by (pool, le) (rate(swarm_ttft_seconds_bucket[5m])))
# completion tokens per second
sum by (pool) (rate(swarm_tokens_out_total[5m]))
# the slowest routes
topk(5, histogram_quantile(0.95, sum by (route, le) (rate(swarm_http_request_duration_seconds_bucket[1h]))))
JSON metrics¶
The UI, CLI and MCP read JSON rather than Prometheus text:
/api/v1/pools/{id}/metrics[/history|/stream], /api/v1/jobs/{id}/metrics/history|stream,
and /api/v1/admin/system (admins; swarm admin system, MCP admin_system).
The pool snapshot's pool.nodes_failed, pool.nodes_stale, pool.incidents_open and
serving.queued, and the job history's rates (steps per minute, tokens/s), are the
numbers the pool pages and the Training console show beside the series above.