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.
Instalación con revisión previa
Este activo requiere revisión. El prompt copiado pide dry-run, muestra escrituras y continúa solo tras confirmación.
npx -y tokrepo@latest install 5c7262a8-3939-11f1-9bc6-00163e2b0d79 --target codexPrimero dry-run, confirma las escrituras y luego ejecuta este comando.
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.
Preguntas frecuentes
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.
Referencias (3)
- cAdvisor GitHub— Container resource monitoring by Google
- Prometheus Documentation— Prometheus metrics exposition format
- Kubernetes Documentation— Kubelet embedded cAdvisor
Relacionados en TokRepo
Discusión
Activos relacionados
bpytop — Resource Monitor with Game-Inspired TUI
A Python-based terminal resource monitor featuring responsive charts, process management, and a visually rich interface inspired by classic game aesthetics.
Coturn — Open Source TURN and STUN Server for WebRTC
A free, open-source TURN and STUN server implementation that provides NAT traversal for WebRTC, VoIP, and real-time communication applications.
Fluentd — Unified Logging Layer for Cloud-Native Infrastructure
Fluentd is a CNCF-graduated open-source data collector that unifies log collection and routing. With 1000+ plugins, it connects any source to any destination — the standard log layer for Kubernetes alongside Fluent Bit.
draw.io — Free Open-Source Diagramming Tool for Any Platform
draw.io is a free, browser-based diagramming application that supports flowcharts, UML, network diagrams, and more. Works offline as a desktop app on Windows, macOS, and Linux with no account required.