Prometheus.exporter.cadvisor for all container

Hi all,

I’m trying to set up prometheus.exporter.cadvisor to monitor all containers. However, I only get metrics for the alloy container itself.

I’m running alloy inside docker container, mounted /var/run/docker.sock inside container

config file:

prometheus.exporter.cadvisor "example" {
  docker_host = "unix:///var/run/docker.sock"

  storage_duration = "5m"
}

// Configure a prometheus.scrape component to collect cadvisor metrics.
prometheus.scrape "scraper" {
  targets    = prometheus.exporter.cadvisor.example.targets
  forward_to = [ prometheus.remote_write.demo.receiver ]
}

prometheus.remote_write "demo" {
  endpoint {
    url = PROMETHEUS_REMOTE_WRITE_URL

    basic_auth {
      username = USERNAME
      password = PASSWORD
    }
  }
}

I’ve not tried this myself, but couple of things you could try:

  1. You might need to mount /var/lib/docker as RO as well.
  2. Make sure your alloy container is privileged.

Hi, I’ve encountered the same problem (I am running Alloy in compose with ‘pid’ and ‘network_mode’ set to ‘host’, without ‘privileged: true’). To get metrics from all containers (via cadvisor component) on the host, I had to add the following volumes:

  • /:/rootfs
  • /var/run:/var/run
  • /sys:/sys
  • /var/lib/docker/:/var/lib/docker