Question of understanding discover.docker and prometheus.exporter.cadivisor

Hi all,

I have a problem of understanding the purposes of discover.docker and prometheus.exporter.cadvisor. We have a docker only environment and want to collect metrics from our containers using Grafana Alloy. Alloy is also running in a container and has the docker.sock mounted. We also have a Grafana + Prometheus Server running in another stack.

Now I have difficulty understanding the purpose of discover.docker and prometheus.exporter.cadvisor. I thought I’d understood that discover.docker is to discover all running containers and do something with that. The main purpose is to export the Logs to a Loki instance. The Prometheus.exporter.cadvisor connects to an cAdivsor and gets the metrics that can be forwarded to Prometheus.

My orientation, what I had to configure was that configuration:

The first thing is, how did the prometheus.exporter.cadvisor know how to reach the cadvisor container? How did the connection between these two services work?
When I deploy the configurations prometheus.exporter.cadvisor and prometheus.scrape" I don’t see any metrics in my Prometheus instance.

When I deploy discovery.docker and prometheus.scrape the targets of discover.docker and deploy the cadvisor container, I see metric in my Prometheus instance. Again the question why? :wink:
How did anyone in this configuration know from the cadvisor container? And if I stop the container the metrics also stops arriving at the Prometheus instance.

Hopefully, anyone can clarify that for me.

Thanks a lot
Regards
Manuel

I am not an expert, but my understand is that cadvisor is its own thing (a toolset to analyze container resource usage and performance), and there is no “cadvisor container”.

Your configuration for cadvisor looks correct to me, if you are not getting metrics I’d double check alloy and see if there is any error log.