stefanprodan / swarmprom

Docker Swarm instrumentation with Prometheus, Grafana, cAdvisor, Node Exporter and Alert Manager
MIT License
1.87k stars 736 forks source link

node-exporter doesn't capture network traffic #48

Closed codestation closed 3 years ago

codestation commented 6 years ago

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?

Albatrosicks commented 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

codestation commented 3 years ago

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