After your environment grows and you add more and more servers at some point the need to have a simple visual monitoring of everything becomes vital.
If you throw into this environment a container environment like docker than you have to monitor even more information.
After creating a docker swarm see Create and manage a Docker Swarm with Docker CE and register it to Docker Cloud I want to be able to see what is going on there.
There is a simple Docker Swarm Visualizer presented as an example by the docker image manomarks/visualizer, but is too basic.
The best solution I found so far is the amazing WeaveScope.
It is an open source tool that can be used to monitor with stunning visuals your servers and as a bonus is fully integrated with docker and able to monitor containers.
WeaveScope is able to create a mesh of sensors that run as docker containers and so are able to get data from the hosts machines and also from the docker environments running on those machines.
STEP 1: Installing Scope on individual nodes of the swarm
The first option is to run everything locally without any outside “cloud”. In this setup we must run WeaveScope on each node of the swarm in a local container.
We will manually peer each node with all of the other nodes during Scope launch. Note that in this mode WeaveScope is not swarm aware and each node can be stopped individually.
STEP 1.1: Run the following on each node that is part of the swarm:
# curl -L git.io/scope -o /usr/local/bin/scope # chmod a+x /usr/local/bin/scope
STEP 1.2: Then on the manager node (nas2.voina.org) launch scope with:
# scope launch nas1.voina.org nas3.voina.org nas4.voina.org
Open port 4040 on which the GUI of WeaveScope will be accesible in the firewall of nas2.
STEP 1.3: Do the same for all of the other nodes in your docker swarm
# scope launch nas2.voina.org nas3.voina.org nas4.voina.org
# scope launch nas1.voina.org nas2.voina.org nas4.voina.org
# scope launch nas1.voina.org nas2.voina.org nas3.voina.org
STEP 1.4: Add additional plugins like the http plugin
On all the nodes start a container from weaveworksplugins/scope-http-statistics
docker run --rm -it \ --privileged --net=host --pid=host \ -v /lib/modules:/lib/modules \ -v /usr/src:/usr/src \ -v /sys/kernel/debug/:/sys/kernel/debug/ \ -v /var/run/scope/plugins:/var/run/scope/plugins \ --name weaveworksplugins-scope-http-statistics weaveworksplugins/scope-http-statistics
To access the GUI of WeaveScope just go to the 4040 port of the swarm master node.
In my case:
STEP 2: Installing Scope on the swarm directly as a service
As an alternative instead of starting on each node individually WaveScope we can deploy it as a service directly on the swarm.
docker service create --name weave-scope --mode global \ --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \ lmarsden/scope-runner scope launch nas1.voina.org nas2.voina.org nas3.voina.org nas4.voina.org
Make sure to list in the command all the nodes of the swarm.
STEP 4.1: Installing Scope on the swarm and register it with Weave Cloud
Go to https://cloud.weave.works and register a free account. You can even use your google account to authenticate if you do not want to create an account.
After creating the account you can see in the page a “Service token: “.
To start the WeaceScope service on the docker swarm with cloud access run on the manager node:
docker service create --name weave-scope --mode global \ --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \ lmarsden/scope-runner scope launch --service-token=#######
where in place of ####### put your service token from the account page.
STEP 4.2: Create a new instance from the docker swarm
From the account page you can create a new instance and group under them the found nodes of the swarm.
The account page will be your WeaveScope GUI in this case.
STEP 5: Using WeaveScope
Does not matter how you register your docker swarm nodes, like in STEP1 or as in STEP2 the GUI is the same.
Display CPU usage on all the nodes
Display the load on all the nodes
Display memory usage on all the nodes
Click on nas2 and display the detailed values for CPU, load, memory with nas2 centered
Note the details panel on the right. We can already notice that WeaveScope is container aware and all the containers on the host are listed with detailed monitoring.
We can go to container mode and display all the running containers on all the nodes. Note that the swarm containers but also the individual node containers are there. Notice the connections between containers.
We can drill down to a container and see its details.
STEP 4: Look and feel video of the WeaveScope monitoring
The look and feel of the GUI is very modern and sleek and easy to use (see the bellow video).
I also like the style of buttons and shapes, it is not ofter to find such a beautifull interface in an free open project.
Note also that this is a cross site solution (nas3 is at 100km from the other nodes linked through a site-to-site VPN) that makes you feel that all your resources are local.
Another bonus point is the full integration with docker. Is running on docker and is fully docker aware making it the best tool to monitor a docker swarm.
I am a big fan of WeaveScope now 🙂