cAdvisor — Real-Time Container Resource Monitoring by Google
Analyze container resource usage and performance with Google's cAdvisor. Native Docker support, Prometheus metrics export, and zero-config deployment for production container monitoring.
What it is
cAdvisor (Container Advisor) is an open-source container monitoring tool maintained by Google. It collects, aggregates, and exports resource usage and performance data from running containers. cAdvisor runs as a single container and auto-discovers all other containers on the host, providing per-container CPU, memory, network, and filesystem metrics.
The tool targets DevOps engineers, SREs, and platform teams running Docker or Kubernetes workloads who need lightweight, always-on container metrics without deploying a full monitoring stack.
How it saves time or tokens
Without cAdvisor, gathering per-container metrics requires parsing docker stats output, writing custom collection scripts, or deploying heavyweight agents. cAdvisor provides a single Docker container that auto-discovers all running containers and exposes metrics in Prometheus format. No configuration files, no agent installation on the host, no custom scripts.
How to use
- Run cAdvisor as a Docker container:
docker run -d --name=cadvisor \
-p 8080:8080 \
--volume=/:/rootfs:ro \
--volume=/var/run:/var/run:ro \
--volume=/sys:/sys:ro \
--volume=/var/lib/docker/:/var/lib/docker:ro \
gcr.io/cadvisor/cadvisor:latest
- Open
http://localhost:8080to view the built-in web UI with container metrics.
- Point Prometheus to
http://localhost:8080/metricsto scrape container metrics for dashboards.
Example
# prometheus.yml - scrape cAdvisor metrics
scrape_configs:
- job_name: 'cadvisor'
scrape_interval: 15s
static_configs:
- targets: ['localhost:8080']
With this Prometheus config, container metrics flow into Grafana dashboards for visualization and alerting.
Related on TokRepo
- Monitoring Tools -- Observability and monitoring tools for infrastructure
- DevOps Tools -- Container orchestration and deployment tools
Common pitfalls
- cAdvisor's built-in web UI is useful for debugging but not suitable for long-term monitoring. Pair it with Prometheus and Grafana for production dashboards.
- Volume mounts must be read-only and match the host filesystem layout. Missing mounts cause incomplete metrics.
- On Kubernetes, cAdvisor is embedded in the kubelet. Running a standalone cAdvisor alongside kubelet can cause duplicate metrics collection.
Frequently Asked Questions
Yes. Kubernetes embeds cAdvisor in the kubelet binary. It provides container metrics that feed into kubectl top, the Metrics Server, and Horizontal Pod Autoscaler. You do not need to deploy cAdvisor separately on K8s clusters.
cAdvisor collects CPU usage, memory usage and limits, network I/O, filesystem reads/writes, and container metadata. Metrics are available per container and per machine.
Yes. cAdvisor exposes metrics in Prometheus format at the /metrics endpoint. Prometheus can scrape this endpoint directly for container monitoring dashboards.
cAdvisor is lightweight. It typically uses less than 100MB of memory and minimal CPU. The overhead is negligible compared to the containers it monitors, making it safe for production hosts.
cAdvisor supports Docker, containerd, and CRI-O container runtimes. It also collects machine-level metrics for the host system regardless of container runtime.
Citations (3)
- cAdvisor GitHub— Container resource monitoring by Google
- Prometheus Documentation— Prometheus metrics exposition format
- Kubernetes Documentation— Kubelet embedded cAdvisor
Related on TokRepo
Discussion
Related Assets
NAPI-RS — Build Node.js Native Addons in Rust
Write high-performance Node.js native modules in Rust with automatic TypeScript type generation and cross-platform prebuilt binaries.
Mamba — Fast Cross-Platform Package Manager
A drop-in conda replacement written in C++ that resolves environments in seconds instead of minutes.
Plasmo — The Browser Extension Framework
Build, test, and publish browser extensions for Chrome, Firefox, and Edge using React or Vue with hot-reload and automatic manifest generation.