3.9 KiB
3.9 KiB
cAdvisor - Container Metrics
Table of Contents
- Overview
- What is cAdvisor?
- Why Use cAdvisor?
- Configuration in AI-Homelab
- Official Resources
- Docker Configuration
Overview
Category: Container Metrics
Docker Image: gcr.io/cadvisor/cadvisor
Default Stack: monitoring.yml
Web UI: http://SERVER_IP:8080
Purpose: Export container metrics
Ports: 8080
What is cAdvisor?
cAdvisor (Container Advisor) analyzes and exposes resource usage and performance metrics from running containers. Created by Google, it provides detailed metrics for each container including CPU, memory, network, and filesystem usage. Essential for Docker monitoring.
Key Features
- Per-Container Metrics: Individual container stats
- Resource Usage: CPU, memory, network, disk
- Historical Data: Resource usage over time
- Web UI: Built-in dashboard
- Prometheus Export: Metrics endpoint
- Auto-Discovery: Finds all containers
- Real-Time: Live metrics
- Free & Open Source: Google project
Why Use cAdvisor?
- Container Visibility: See what each container uses
- Resource Tracking: CPU, memory, I/O per container
- Prometheus Integration: Standard exporter
- Google Standard: Industry trusted
- Auto-Discovery: No configuration needed
- Web UI: Built-in visualization
Configuration in AI-Homelab
No configuration files needed. cAdvisor auto-discovers containers.
Official Resources
- GitHub: https://github.com/google/cadvisor
- Documentation: https://github.com/google/cadvisor/blob/master/docs/storage/prometheus.md
Docker Configuration
cadvisor:
image: gcr.io/cadvisor/cadvisor:latest
container_name: cadvisor
restart: unless-stopped
networks:
- traefik-network
ports:
- "8080:8080"
privileged: true
devices:
- /dev/kmsg
volumes:
- /:/rootfs:ro
- /var/run:/var/run:ro
- /sys:/sys:ro
- /var/lib/docker:/var/lib/docker:ro
- /dev/disk:/dev/disk:ro
Note: Requires privileged: true and many volume mounts to access container metrics.
Metrics Available
CPU
container_cpu_usage_seconds_total- CPU usage per containercontainer_cpu_system_seconds_total- System CPU usagecontainer_cpu_user_seconds_total- User CPU usage
Memory
container_memory_usage_bytes- Memory usagecontainer_memory_working_set_bytes- Working setcontainer_memory_rss- Resident set sizecontainer_memory_cache- Page cachecontainer_memory_swap- Swap usage
Network
container_network_receive_bytes_total- Bytes receivedcontainer_network_transmit_bytes_total- Bytes transmittedcontainer_network_receive_errors_total- Receive errorscontainer_network_transmit_errors_total- Transmit errors
Filesystem
container_fs_usage_bytes- Filesystem usagecontainer_fs_reads_bytes_total- Bytes readcontainer_fs_writes_bytes_total- Bytes written
Summary
cAdvisor provides container metrics offering:
- Per-container resource usage
- CPU, memory, network, disk metrics
- Auto-discovery of containers
- Web UI dashboard
- Prometheus export
- Real-time monitoring
- Free and open-source
Perfect for:
- Docker container monitoring
- Resource usage tracking
- Performance analysis
- Identifying resource hogs
- Capacity planning
Key Points:
- Google's container advisor
- Auto-discovers all containers
- Built-in web UI
- Prometheus integration
- Requires privileged mode
- Port 8080 for UI and metrics
- Grafana dashboard 14282
Remember:
- Add to Prometheus config
- Import Grafana dashboard
- Privileged mode required
- Many volume mounts needed
- Web UI at :8080
- Low overhead
cAdvisor monitors all your containers!