akerouanton/swarm-tasks-exporter
This little Prometheus exporter provides two metrics to better monitor Swarm tasks and their state.
In its current state, the exporter does:
swarm_service_desired_replicas
: Gauge of how many replicas is desired, for
every Swarm service (labels: stack
, service
, service_mode
).swarm_service_replicas_state
: Gauge of tasks state (labels: stack
,
service
, service_mode
, state
).This exporter is available on Docker Hub: akerouanton/swarm-tasks-exporter
:
docker run -v /var/run/docker.sock:/var/run/docker.sock:ro akerouanton/swarm-tasks-exporter
Or, with docker-compose (or Swarm):
services:
tasks_exporter:
image: akerouanton/swarm-tasks-exporter:0.1.0
command: -log-level error
volumes:
- '/var/run/docker.sock:/var/run/docker.sock:ro'
networks:
- monit_prometheus
deploy:
replicas: 1
restart_policy:
condition: on-failure
placement:
constraints:
- node.role == manager
As you can see, when you want to deploy it to a Swarm cluster, it has to be scheduled on a manager node, or it won't be able to access cluster events.
You can use following flags to configure the exporter:
-listen-addr <ip:port>
: IP address and port to listen to (default 0.0.0.0:8888).-poll-delay
: Delay in seconds between two polls (default 10s).-label
: Add custom labels to metrics-log-format
: How log should be formatted. Either json or text (default text).-log-level
: What's the minimum level of logs. Either debug, info, warn,
error, fatal or panic (default info).Moreover, this exporter supports the same env vars as the docker client:
DOCKER_HOST
to set the url to the docker serverDOCKER_CERT_PATH
to load the TLS certificates from.DOCKER_TLS_VERIFY
to enable or disable TLS verification, off by default.docker pull akerouanton/swarm-tasks-exporter