A sample image that can be used as a base for collecting Swarm mode metrics in Prometheus
You can use the provided docker-stack.yml
file as an example. You can deploy the full stack with the command:
Before deploying, you need to create an overlay network for monitoring with prometheus
docker network create --driver overlay --attachable monitoring
Prometheus uses internal TSDB which needs a persistent volume I set the constraint on Prometheus service therefore you should set the service=prometheus label
docker node update --label-add service=prometheus infa-swarm-t1003
docker stack deploy -c docker-compose-stack.yml prometheus
You might need to apply this IPTables rule to work docker-exporter service This rule will allow the container to reach the host on it's own exposed port which is 4999 moby/moby#24370
iptables -I INPUT 1 -i docker_gwbridge -j ACCEPT
docker stack deploy -c grafana.yml grafana
Now you can access your Grafana dashboard via this URL
- http://:3000
You can find some predefined dashboard JSON files in the grafana directory
Import them to create essential dashboards
- Prometheus 2.0 stats Dashboard: prometheus-stats.json
- Docker Swarm Nodes Dashboard: docker-swarm-node.json
- Docker Swarm Services Dashboard: docker-swarm-service.json
- Node Exporter Full Dashboard: node-exporter.json