Closed codestation closed 3 years ago
node-exporter must be run in privileged mode. You can't do it in the compose file for swarm stack. But you can change your compose file like this:
node-exporter:
image: stefanprodan/swarmprom-node-exporter:v0.16.0
networks:
- net
user: <user>:<gid> # required when running in a swarm without sudo - use the <gid> of docker group of swarm
ex. user: root:0
I did a workaround involving running the container using the host network then using socat sidecar container to expose the node-exporter port in the docker network.
Now i just connect to the socat container instead of the node-exporter one.
node-exporter-proxy:
image: alpine/socat:latest
command: tcp-listen:9100,fork,reuseaddr tcp-connect:172.18.0.1:9100
networks:
- net
In the current stack the node-exporter services cannot capture the network traffic stats since they aren't attached to the host network.
If one does switch to use the host network then it works fine again but Prometheus cannot discover the exporters anymore.
Is there a way to support both discover and host networking or i have to choose between the two features when using this stack?