Skip to content

Files

Latest commit

a651225 · Feb 10, 2022

History

History

swarm

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Feb 10, 2022
Feb 7, 2022
Feb 8, 2022

Docker Swarm

NOTE: For this demo you will need to run Docker in Swarm mode.

docker swarm init > /dev/null

Copy docker-stack.yml and prometheus.yml to a local directory and proceed to deploy the stack locally...

# create demo directory
mkdir docker-event-metrics-demo
cd docker-event-metrics-demo

# copy required config
uri=https://raw.githubusercontent.com/rjchicago/docker-event-metrics/master/examples/swarm/
curl ${uri}docker-stack.yml -o docker-stack.yml
curl ${uri}prometheus.yml -o prometheus.yml

#deploy
docker stack deploy -c docker-stack.yml docker-event-metrics --prune

# check services until all are up and running
docker service ls 

test

Create some test events...

docker network create test
docker network rm test
docker run --rm alpine echo "hello"
docker service update --replicas 3 docker-event-metrics_test
docker service rm docker-event-metrics_test

# create a flapping container
docker service create \
 --restart-condition any \
 --name docker-event-metrics_testy \
 alpine \
 sleep 10

Open ./metrics endpoints:

prometheus

Open in Prometheus...

Example graph...

rate(docker_events[2m]) > 0

Looking specifically at container starts...

rate(docker_events{type="container", action="start"}[2m]) > 0

cleanup

docker stack rm docker-event-metrics
docker service rm docker-event-metrics_testy