Measure network traffic per host via prometheus

I want to build a Grafana dashboard that shows the network traffic per host connected to my Linksys WRT1900AC router which is running OpenWRT release 19.07.3.

I have installed the following packages:

  • prometheus-node-exporter-lua
  • prometheus-node-exporter-lua-nat_traffic
  • prometheus-node-exporter-lua-netstat
  • prometheus-node-exporter-lua-openwrt
  • prometheus-node-exporter-lua-wifi
  • prometheus-node-exporter-lua-wifi_stations

... and imported the following Grafana dashboard: https://grafana.com/grafana/dashboards/11147

Now I want to add a custom panel which shows the transmit and received kbps per host. For the hosts connected via WIFI, I can use the metrics shown in the sample below and filter by the various MAC addresses.

wifi_station_transmit_kilobits_per_second{mac="E0:DB:10:38:DB:5F",ifname="wlan0"} 26000
wifi_station_receive_kilobits_per_second{mac="E0:DB:10:38:DB:5F",ifname="wlan0"} 48000
wifi_station_transmit_packets_total{mac="E0:DB:10:38:DB:5F",ifname="wlan0"} 177322
wifi_station_receive_packets_total{mac="E0:DB:10:38:DB:5F",ifname="wlan0"} 62329

However I cannot find similar metrics per MAC address for hosts that are connected via LAN.

What do you recommend?

Hey, Sorry I'm not gonna be much use. But more would like to know how you get the data into Prometheus? I installed all the lua packages, but don't know where to make the changes on prometheus to expose the metrics in grafana. All I see in grafana are the metrics internal to prometheus.

Thanks in advance!

Hello,

First I would recommend to check that the node exporter is correctly installed on your openwrt router, and that it is listening on port 9100. As an example, if your router IP address is 192.168.2.50, use a browser on the host where Prometheus is installed and type this url:

http://192.168.2.50:9100/metrics

That should return a list of metrics.

Next step is to add the openwrt exporter to the section static_configs in the prometheus.yml config file. Assuming same IP address, you need to add:

    static_configs:
    - targets: ['localhost:9090']
    - targets: ['192.168.2.50:9100']

Finally, restart the prometheus service.

sudo systemctl restart prometheus

Hope this helps.

Thanks. Mine is@ 10.0.1.1, so i did try http://10.0.1.1:9100 and got a refused to connect.

So that I'm sure is where my issue lies.

When you say add to the prometheus.yml config file, is that a yml file on the opnwrt? or do you have a centralized prometheus in your network that is accepting endpoint inputs from multiple targets? Seems like the former. But I haven't been able to get the multiple targets thing to work. I have two ubuntu vms spun up and had to install prometheus on each, then add separate data sources and use http://ip address:9090 for each data source in grafana. BTW, if you couldn't tell, I'm on like my second day using prometheus/grafana. So thanks for your suggestion above.