What Is cAdvisor?
cAdvisor (Container Advisor) is a tool from Google that monitors running Docker containers. It collects resource usage, performance data, and provides a web UI and API.
Run cAdvisor
docker run -d \
--name=cadvisor \
--restart=unless-stopped \
-p 8080:8080 \
-v /:/rootfs:ro \
-v /var/run:/var/run:ro \
-v /sys:/sys:ro \
-v /var/lib/docker:/var/lib/docker:ro \
gcr.io/cadvisor/cadvisor:latestAccess the Dashboard
Open http://your-ip:8080 to see:
- CPU usage per container
- Memory usage and limits
- Network I/O
- Disk I/O
- Container filesystem usage
Prometheus Integration
cAdvisor exposes metrics at /metrics in Prometheus format:
# prometheus.yml
scrape_configs:
- job_name: cadvisor
static_configs:
- targets: ["localhost:8080"]Key Metrics
| Metric | Description |
|---|---|
container_cpu_usage_seconds_total | CPU time consumed |
container_memory_usage_bytes | Current memory usage |
container_network_receive_bytes_total | Network bytes received |
container_fs_usage_bytes | Filesystem usage |
Grafana Dashboard
Import the Docker monitoring dashboard (ID: 893) in Grafana for pre-built visualizations of all container metrics.