node_exporter icon indicating copy to clipboard operation
node_exporter copied to clipboard

add route table and route type label

Open derrickhayashi opened this issue 2 years ago • 1 comments

This PR adds labels to show the route table for a particular route as well as the route type.

On a router, it is common to use different route tables to differentiate and isolate networks (known as VRFs in the networking world) for multiple tenants. The original PR does not seem to differentiate between different route tables (no response to https://github.com/prometheus/node_exporter/pull/1811#issuecomment-673310433) so this PR adds this feature. It also looks up the route table id to a user friendly name as defined in rt_tables config.

Also, "blackhole" route types are a route to ensure that packets destined for networks which the router is not able to route to do not keep propagating. On Linux, there are two options to do this, either through the route type of "blackhole", which silently discards the packet, or "unreachable", which sends an ICMP unreachable message.

On a device functioning as a router, it is usable to be able to monitor and identify these routes and types.

Example output

$ ip r show table test
blackhole 192.0.2.1
unreachable 192.0.2.2
$ cat /etc/iproute2/rt_tables.d/
README     test.conf
$ cat /etc/iproute2/rt_tables.d/test.conf
32 test
$ ip r show table test
blackhole 192.0.2.1
unreachable 192.0.2.2
$ curl -s localhost:9100/metrics | grep node_network_route | grep "192\."
node_network_route_info{dest="192.0.2.1/32",device="",gw="",priority="0",proto="boot",src="",table="test",type="blackhole",weight=""} 1
node_network_route_info{dest="192.0.2.2/32",device="",gw="",priority="0",proto="boot",src="",table="test",type="unreachable",weight=""} 1
node_network_route_info{dest="192.168.1.0/24",device="enp0s31f6",gw="",priority="100",proto="kernel",src="192.168.1.11",table="main",type="unicast",weight=""} 1
node_network_route_info{dest="192.168.1.1/32",device="enp0s31f6",gw="",priority="100",proto="dhcp",src="192.168.1.11",table="main",type="unicast",weight=""} 1
node_network_route_info{dest="default",device="enp0s31f6",gw="192.168.1.1",priority="100",proto="dhcp",src="192.168.1.11",table="main",type="unicast",weight=""} 1
$

derrickhayashi avatar Jun 26 '23 13:06 derrickhayashi