Giter Club home page Giter Club logo

Comments (5)

lutzky avatar lutzky commented on May 5, 2024 9

A big part of the reason this doesn't work is that /proc/net/dev inside a container will only show the container-local devices, even if it's mounted (it probably has to do with /proc/net being a symlink to /proc/self/net, which in turn goes by the current PID).
Using network_mode: host means prometheus config needs to be changed.

Here's an easier way, seeing as we already have cadvisor set up: In grafana, use the following queries:

sum(rate(container_network_receive_bytes_total{id="/",interface!~"br.*|lo"}[1m]))
sum(rate(container_network_transmit_bytes_total{id="/",interface!~"br.*|lo"}[1m]))

Alternatively, use interface="eno1" for your specific case (and then you can drop the external sum).

from dockprom.

k-s-dean avatar k-s-dean commented on May 5, 2024

In the docker-compose.yml, change the following.

 ports:
   - 9090:9090

to

    ports:
      - "192.168.0.1:9090:9090"

So specify the IP of the interface you wish your containers to bind to.

    ports:
      - "<YOUR enp1s0fo IP>9090:9090"

hope that helped

kind regards.

from dockprom.

johnbritto1 avatar johnbritto1 commented on May 5, 2024

The fix isn't working. The Network Usage graphs of "Docker Host" in grafana doesn't show any traffic update. Please help.

from dockprom.

nightah avatar nightah commented on May 5, 2024

There's two elements that need to change to achieve this.
The default docker-compose.yml monitors the ethernet interface of the node_exporter instance (which isn't your host).

Alternatively you could run the node_exporter instance in the docker-compose.exporters.yml file:

nodeexporter:
    image: prom/node-exporter:v0.17.0
    container_name: nodeexporter
    user: root
    privileged: true
    volumes:
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /:/rootfs:ro
    command:
      - '--path.procfs=/host/proc'
      - '--path.sysfs=/host/sys'
      - '--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($$|/)'
    restart: unless-stopped
    ports:
      - 9100:9100
    network_mode: host
    labels:
      org.label-schema.group: "monitoring"

Or modify your default docker-compose.yml to reflect the host interface like such:

nodeexporter:
    image: prom/node-exporter:v0.17.0
    container_name: nodeexporter
    user: root
    privileged: true
    volumes:
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /:/rootfs:ro
    command:
      - '--path.procfs=/host/proc'
      - '--path.sysfs=/host/sys'
      - '--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($$|/)'
    restart: unless-stopped
    expose:
      - 9100
    network_mode: host
    labels:
      org.label-schema.group: "monitoring"

After this change you then need to modify your Docker Host Grafana dashboard to reflect the actual ethernet interface on your host. For example mine is eno1 so the following:

  • irate(node_network_receive_bytes_total{device="eth0"}[1m])
  • irate(node_network_transmit_bytes_total{device="eth0"}[1m])

Should read:

  • irate(node_network_receive_bytes_total{device="eno1"}[1m])
  • irate(node_network_transmit_bytes_total{device="eno1"}[1m])

from dockprom.

DoTheEvo avatar DoTheEvo commented on May 5, 2024

lutzky solution works for me and is super easy.

Any reason Why its not incorporated in to the project?

from dockprom.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.