FoxuTech

How to Monitor Containers with cAdvisor

How to Monitor Containers with cAdvisor

cAdvisor (Container Advisor) provides container users an understanding of the resource usage and performance characteristics of their running containers. It is a running daemon that collects, aggregates, processes, and exports information about running containers. Specifically, for each container it keeps resource isolation parameters, historical resource usage, histograms of complete historical resource usage and network statistics. This data is exported by container and machine-wide.

cAdvisor has native support for Docker containers and should support just about any other container type out of the box. We strive for support across the board so feel free to open an issue if that is not the case. cAdvisor’s container abstraction is based on lmctfy‘s so containers are inherently nested hierarchically.

cAdvisor is a monitoring tool, open sourced by Google which can present the monitoring and performance data in various forms. cAdvisor run a daemon and collects the data per container and for overall host. This data can be consumed in the following ways:

cAdvisor can run on a host in two ways, as a standalone binary or as a Docker container. We will see both the ways in this post.

cAdvisor as a Standalone Binary

cAdvisor publishes standalone binaries on their release page. These binaries can be downloaded and run directly.

# wget https://github.com/google/cadvisor/releases/download/v0.26.1/cadvisor
# chmod 755 cadvisor
# ./cadvisor

By default, cAdvisor runs the web interface on port 8080. So, we will go on our browser and checkout the web interface at http://localhost:8080. Note that cAdvisor is aware of cgroups and namespaces. So, in addition to the containers, processes running on the hosts are also visible and can be monitored.

cAdvisor as a Docker Container

For environments where running a binary is not possible, cAdvisor provides a docker container which can be used to run the cAdvisor daemon.

# docker run --volume=/:/rootfs:ro --volume=/var/run:/var/run:rw --volume=/sys:/sys:ro --volume=/var/lib/docker/:/var/lib/docker:ro --publish=8080:8080 --detach=true --name=cadvisor1 google/cadvisor:latest

Note:  that on Red Hat, CentOS and Fedora, we may need to pass –privileged=true because of security measures enforced on the containers by SELinux (it is a good thing).

Now we can just browse the monitoring graphs at http://localhost:8080.

Read More: Monitor Docker Host Environment using Prometheus

Graphs:

Processes:

CPU:

Memory:

Sub Containers:

Roadmap

cAdvisor aims to improve the resource usage and performance characteristics of running containers. Today, we gather and expose this information to users. In our roadmap:

Exit mobile version