cAdvisor is an amazing tool. It is an all-in-one tool for grabbing real-time metrics from all the containers running on a single host and exposing these metrics. The cAdvisor collects, aggregates, processes, and exports usage and performance information from running containers.
In this section we will deploy a cAdvisor container and walk through the UI, configurations, and take a look at the metrics which it exposes.
Tasks:
Let's get started with deploying cAdvisor. First, we will review the cAdvisor GitHub Repos. The repo contains a wealth of documentation from using the UI to configurations. Take some time and dive into the different aspects of cAdvisor.
We recommend using Play-with-Docker for this exercise to alleviate any permissions issues or Windows issues with having to run sudo.
-
Navigate to cAdvisor GitHub Repo
-
Deploy cAdvisor:
PWD USERS
sudo docker service create \ --publish published=8081,target=8080 \ --detach=true \ --name=cadvisor \ google/cadvisor:latest
Since we are using
PWD
we cannot don't have permissions to bind mount root directories. For normal deployments please review the cAdvisor documentation
**Docker for Desktop**
```
sudo docker run \
--volume=/:/rootfs:ro \
--volume=/var/run:/var/run:ro \
--volume=/sys:/sys:ro \
--volume=/var/lib/docker/:/var/lib/docker:ro \
--volume=/dev/disk/:/dev/disk:ro \
--publish=8080:8080 \
--detach=true \
--name=cadvisor \
google/cadvisor:latest
```
- Once the cAdvisor is running open the UCP -> Swarm -> Services -> cAdvisor link 8081 which is located at the top of the screen
Have a look at the cAdvisor UI. What we see here is a host performance view. Scroll through the various screens to view Reservations, CPU, Memory, Network, and Storage.
- Scroll to the top of the screen and click
Docker Containers
Here we see all the
Compose Demo Stack
containers. Choose one of the containers and view the specific resource consumption of just that particular container.
Now, we will have a look to see how cAdvisor exposes the metrics it is gathering from running containers. As default, cAdvisor exposes metrics in the Prometheus format
docker stack rm vote
docker rm -f cadvisor
What did we learn in this section?
- Google's Container advisor
cAdvisor
- Deploy cAdvisor UI and configurations
- cAdvisor exposed metrics
For the next step in the tutorial, head over to Prometheus