0

I have a Prometheus instance scraping from snmp_exporter, and I have two metrics I need to join, with the aim to marry up IP addresses and network interfaces on SNMP-capable devices, based on the "ifIndex" number it is referenced by in SNMP:

Metric Value (ifIndex)
ifIndex{ifAlias="Cust:", ifDescr="GigabitEthernet0/0/0", ifIndex="2", ifName="Gi0/1/0", instance="192.168.0.1", job="snmp"} 2
ipAddressIfIndex{instance="192.168.0.1", ipAddressAddr="1.1.1.1", job="snmp"} 2

Both metrics return the ifIndex as a value, but only one includes it as a label. I'm familiar with how to join metrics based on matching labels, but so far have been unable to find a method for matching on the values.

I've also come at this the other way, by reconfiguring snmp_exporter to include an ifIndex label in ipAddressIfIndex. Undoubtedly this would be the preferred option, but documentation is unclear on how I might go about that, and experimentation has failed so far.

For background, the ipAddressAddr label contains the (redacted) IP of a second interface on the device, so sadly it's not as simple as using the instance address.

1 Answers1

0

You can do such a join using == and group_left. For example provided in question something like this.

ifIndex == on(instance) group_left(ipAddressAddr) ipAddressIfIndex

This query will take all pair of metrics ifIndex and ipAddressIfIndex with the same instance, compare them, and return ifIndex with label ipAddressAddr of ipAddressIfIndex with the same value (if exists).

Example of similar "join" can be seen here.

markalex
  • 363
  • 2
  • 13