I'm using docker swarm and a public network for my containers. But I need to monitor traffic usage on the machine hosting the container (whichever that is). node_network_receive_bytes_total seems to be the metric for that but it is measuring the container traffic, not the host's. ChatGPT recommended the following configuration, which I expected to work. It also suggested using the volume - /var/run/netns:/var/run/netns:ro but there isn't a /var/run/netns on my machine.
I cannot use network: local so this question is not helpful. Also this one is inconclusive
node_exporter:
image: ubuntu/alertmanager:0.25.0-22.04_stable
pid: "host"
networks:
- my-proxy-public
volumes:
- /sys:/host/sys:ro
- /:/rootfs:ro
- /proc:/host/proc:ro
- /etc/hostname:/etc/nodename
deploy:
mode: global
command:
- '--path.procfs=/host/proc'
- '--path.rootfs=/rootfs'
- '--path.sysfs=/host/sys'
- '--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($$|/)'
- '--collector.textfile.directory=/home/'
- '--collector.meminfo_numa'
- '--no-collector.ipvs'
How can I effectively monitor the traffic usage on the host machine instead of the container?