This repo is inspired from a slack post from bvis in the docker community slack how to export dynamically your engine metrics.
The clue is that you export docker_gwbridgeinterface in the swarm cluster. and there is the engine accessible
For example do this for 3 nodes
docker-machine create --driver xhyve \
--xhyve-boot2docker-url=https://github.com/boot2docker/boot2docker/releases/download/v1.13.0-rc4/boot2docker.iso \
node01ip -o -4 addr show docker_gwbridge | awk -F '[ /]+' '/global/ {print $4}'In my case it was 172.18.0.1 .
cat > /etc/docker/daemon.json <<EOF
{
"experimental":true,
"metrics-addr":"0.0.0.0:5050"
}
EOFAfter you did this restart or reload your engine .
Terminal 1:
eval $(dm env node01)Terminal 2:
eval $(dm env node02)Terminal 3:
eval $(dm env node03)docker build -t solidnerd/prometheus-docker-exporter prometheusdocker build -t solidnerd/socat socatThis step depends on you
Create your monitoring network.
docker network create -d overylay monitoringSo expose your engine metrics in the swarm cluster.
docker \
service create \
--mode global \
--name docker-exporter \
--network monitoring \
--env IN="172.18.0.1:5050" \
--env OUT="5050" \
--publish 5051:5050 \
solidnerd/socatStart your prometheus engine.
docker service create \
--name prometheus \
--network monitoring \
--publish 9090:9090 \
--constraint 'node.hostname==node01' \
solidnerd/prometheus-docker-exporter