nodeexporter container should utilize "host" networking driver to also collect host level network metrics
Kami opened this issue · comments
Right now nodeexporter
and other containers as part of this deployment utilize bridge
network driver.
Even though /
host file system is mounted into this container, network interface metrics will only be collected for the nodeexporter container and not for host.
The reason for that is that /proc/net -> self/net
is a symlink which gets resolved to self/net
inside the container which means only container metrics will be retrieved.
To also collect metrics for other host interfaces, the easiest approach is to change network type to host
:
nodeexporter:
image: prom/node-exporter:v1.3.0
container_name: nodeexporter
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
...
restart: unless-stopped
expose:
- 9100
ports:
- 127.0.0.1:9100:9100
# We run it in host network mode so we get access to metrics for all the
# interfaces
network_mode: host
And then prometheus config also needs to be updated to utilize internal IP for the nodeexporter target.
For example:
scrape_configs:
- job_name: 'nodeexporter'
scrape_interval: 30s
static_configs:
#- targets: ['nodeexporter:9100']
# If network_mode host is used for node exporter, we need to use host
# internal IP
- targets: ['192.168.168.10:9100']
If there are no objections, I will open a PR which explains this in the readme.
That's what https://github.com/stefanprodan/dockprom/blob/master/docker-compose.exporters.yml is for.
Happy for you to PR an explanation and referring to that file in the README though.
That file isn't even mentioned in the Readme. I suppose we should use the contents of that file instead, for those 2 containers? Why not simply have 2 complete compose files?
The whole point of this issue and discussion was regarding updating the README.
You can use the extend syntax, replace the networking mode in the main docker-compose.yml
or override/pull in the docker-compose.exporters.yml
.
There's not just a single way to achieve this outcome.
@nightah thanks I didn't know about using multiple compose files! But I will stick with one for now :)
But the exporters.yml doe not contain this part below, without this, since nodeexporter and cadvisor are not in the same docker network as Prometheus, isn't this required?
And then prometheus config also needs to be updated to utilize internal IP for the nodeexporter target.
For example:
scrape_configs: - job_name: 'nodeexporter' scrape_interval: 30s static_configs: #- targets: ['nodeexporter:9100'] # If network_mode host is used for node exporter, we need to use host # internal IP - targets: ['192.168.168.10:9100']If there are no objections, I will open a PR which explains this in the readme.
Yes that's right if you plan to use the other Dockerfile you will need to also adjust your Prometheus configuration to point to the host to capture metrics.