Skills2026年4月16日·1 分钟阅读

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.

Agent 就绪

先审查再安装

这个资产需要先审查。复制的指令会要求 Agent dry-run、列出写入项,确认后再继续。

Needs Confirmation · 64/100策略:需确认
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
cAdvisor Container Monitoring
先审查命令
npx -y tokrepo@latest install 5c7262a8-3939-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run,确认写入项后再运行此命令。

TL;DR
cAdvisor monitors container CPU, memory, network, and disk usage in real time with zero configuration and Prometheus integration.
§01

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.

§02

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.

§03

How to use

  1. 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
  1. Open http://localhost:8080 to view the built-in web UI with container metrics.
  1. Point Prometheus to http://localhost:8080/metrics to scrape container metrics for dashboards.
§04

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.

§05

Related on TokRepo

§06

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.

常见问题

Is cAdvisor included in Kubernetes?+

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.

What metrics does cAdvisor collect?+

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.

Does cAdvisor support Prometheus?+

Yes. cAdvisor exposes metrics in Prometheus format at the /metrics endpoint. Prometheus can scrape this endpoint directly for container monitoring dashboards.

How much overhead does cAdvisor add?+

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.

Can cAdvisor monitor non-Docker containers?+

cAdvisor supports Docker, containerd, and CRI-O container runtimes. It also collects machine-level metrics for the host system regardless of container runtime.

引用来源 (3)

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产