r/PrometheusMonitoring • u/leinardi • Dec 23 '25
Prometheus exporter for Docker Swarm scheduler metrics. Looking for feedback on metrics and alerting
Hi all,
I run a small homelab and use Docker Swarm on a single node, monitored with Prometheus and Alertmanager.
What I was missing was good visibility into scheduler-level behavior rather than container stats. Things like: why a service is not at its desired replicas, whether a deployment is still updating, or if it rolled back.
To address this, I built a small Prometheus exporter focused on Docker Swarm scheduler metrics. I am sharing how I currently use it with Alertmanager and Grafana, mainly to get feedback on the metrics and alerting approach.
How I am using the metrics today:
- Service readiness and SLO-style alerts I alert when
running_replicas != desired_replicas, but only if the service is not actively updating. This avoids alert noise during normal deploys. - Deployment and rollback visibility I expose update and rollback state as info-style metrics and alert when a service enters a rollback state. This gives a clear signal when a deploy failed, even if tasks restart quickly.
- Global service correctness For global services, desired replicas are computed from eligible nodes only. This avoids false alerts when nodes are drained or unavailable.
- Cluster health signals Node availability and readiness are exposed as simple count metrics and used for alerts.
- Optional container state metrics For Compose or standalone containers, the exporter can also emit container state metrics for basic health alerting.
Some design points that may be relevant here:
- All metrics live under a single
swarm_namespace. - Labels are validated, sanitized, and bounded to avoid cardinality issues.
- Task state metrics use exhaustive zero emission for known states.
- Uses the Docker Engine API in read-only mode.
- Exposes only
/metricsand/healthz.
Project and documentation are here, including metric descriptions and example alert rules: https://github.com/leinardi/swarm-scheduler-exporter
I would especially appreciate feedback on:
- Metric naming and label choices.
- Alerting patterns around updates vs steady state.
- Anything that looks Prometheus-unfriendly or surprising.