cAdvisor: A Task Manager for Containers
cAdvisor is like a task manager for your containers, giving you a live view of their resource usage. It's used to track performance, historical usage, and network stats for every container on a host.
WHY IT EXISTS: Running applications in containers creates a visibility problem. Without a specialized tool, it's difficult to answer a simple question: which container is consuming how much CPU, memory, or network I/O on a host? This makes troubleshooting performance issues and capacity planning nearly impossible.
THE MENTAL MODEL: Think of cAdvisor as a lightweight, container-aware top command that runs as a service. It's a daemon that lives on a host machine, peers into the running containers, and exposes their performance metrics through an API for other tools to consume. It's not the dashboard itself, but the data source for the dashboard.
HOW IT WORKS: cAdvisor runs as a daemon, typically in its own Docker container. It collects, aggregates, processes, and exports information about all running containers on its host. This includes resource isolation parameters, historical resource usage (like CPU and memory), complete histograms of that usage, and network statistics. Its container abstraction is inherently hierarchical, allowing it to understand nested container relationships. It has native support for Docker and is designed to work with other container runtimes out of the box.
WHEN TO USE IT: Use cAdvisor as a foundational data source for container monitoring. It's a standard way to get raw, real-time performance data from every container on a node. It is especially critical in Kubernetes, where it is often integrated into the Kubelet component on each node to provide the metrics that drive pod auto-scaling and scheduling decisions.
WHEN NOT TO USE IT: Do not rely on cAdvisor as a standalone, complete monitoring solution. It is designed to be a data exporter, not a long-term storage or visualization system. For alerting, long-term trend analysis, and dashboarding, you must pair cAdvisor with a time-series database like Prometheus to scrape and store its metrics, and a tool like Grafana to build visualizations.
ONE CANONICAL EXAMPLE: The quickest way to try cAdvisor is by running its official Docker image. A minimal command is sudo docker run --volume=/:/rootfs:ro ... google/cadvisor:<VERSION>. This command uses a volume mount to give the cAdvisor container access to the host's root filesystem. This access is how cAdvisor discovers and gathers metrics from all other running containers on the machine. A complete, practical command would also map ports to access cAdvisor's web UI.
Read the original → github.com
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.