Info
Content

WAN Up/Down And Router Uptime Metrics

wan_up_down.jpg

This tutorial is Windows specific, although many items are cross-platform compatible.

Dependencies

  • Grafana
  • Prometheus
  • Prometheus SNMP connector
  • A router with SNMP output

1. Check if your router has SNMP output

I'm using a Netgear AC6700 router which does not natively support SNMP out. I had to flash the router's firmware with DD-WRT. Most home routers, even high-end routers, do not by default have SNMP output. If this is the case with your router, you will have to flash your router's firmware with DD-WRT.

You must match your router's model number EXACTLY in the DD-WRT router database. Failure to do so could brick your router. If your router is not listed, I do not recommend carrying out this firmware upgrade.

2. Enable SNMP output on your router

In my particular case, once I installed the DD-WRT firmware on my router the option to enable SNMP became available in the router's web administration panel. This process may or may not be different on your router.

enable_snmp.JPG

3. Confirm that SNMP is outputting metrics

Click here to download MIB Browser, then install and run it.

Once you've started MIB Browser, enter the IP address of your router at the top left-hand corner of the screen:

enter_router_ip_address.JPG

And then press Go:

press_go.JPG

Now expand the file tree on the left and double click the SysDescr metric. The data for that metric should pop up in the panel on the right. In my case, I know this SNMP metric is working properly because I named my router "Omnius", and the sysDesr metric has read and displayed that name.

snmp_out_confirm.JPG

If MIB Browser does not begin picking up metrics from your router at this point, then Prometheus won't pick anything up either.

4. Find the OIDs that match your router's WAN input and output

An OID is a numerical indicator of a particular SNMP metric. In my case I have the DD-WRT firmware installed on my router, so I searched Google for "DD-WRT WAN OIDs" and was presented with this page:

https://wiki.dd-wrt.com/wiki/index.php/Multi_Router_Traffic_Grapher

And on this page is the WAN up/down OID:

wan_metrics.JPG

5. Configure Prometheus to target the router's IP

Open prometheus.yml with a text editor in the Prometheus folder, and then enter the IP address of your router as the target SNMP device:

prometheusyml.JPG

6. Restart Prometheus and the Prometheus SNMP connector.

This will force both applications to pick up the new configuration you just made.

7. Add Prometheus as a data source in Grafana

prometheus_data_source.JPG

8. Create a new graph in Grafana for WAN Incoming

Panel type: Graph

Set the data source to Prometheus:

prometheus_data_source2.JPG

And input the WAN Incoming query as follows:

prometheus_query.JPG

If necessary, copy and paste the query from here, modifying it to suit your particular situation:

sum by(status)(irate(ifInOctets{ifDescr="vlan2",ifIndex="8",instance="192.168.1.1",job="snmp"}[20m]))

And you should end up with this graph:

wan_incoming.JPG

9. Create a new graph in Grafana for WAN Outgoing

Panel type: Graph

Set the data source to Prometheus:

prometheus_data_source2.JPG

And input the WAN outgoing query as follows:

prometheus_query.JPG

If necessary, copy and paste the query from here, modifying it to suit your particular situation:

sum by(status)(irate(ifOutOctets{ifDescr="vlan2",ifIndex="8",instance="192.168.1.1",job="snmp"}[20m]))

And you should end up with this graph:

wan_outgoing.JPG

10. Router uptime panel

Panel type: Singlestat

router_uptime.JPG

Set the data source to Prometheus:

prometheus_data_source2.JPG

And input the system uptime query as follows:

prometheus_query.JPG

Here is the actual query:

SELECT mean("System Uptime") / 100 FROM "snmp" WHERE ("agent_host" = '192.168.1.1') AND $timeFilter GROUP BY time(1h)
Back to top