I am trying to gather counts of BGP prefixes sent to each peer from a Juniper router, using snmp_exporter. There is a SNMP metric for this: jnxBgpM2PrefixOutPrefixes
, however this indexes on this do not have the local and remote peer addresses, instead have a index called jnxBgpM2PeerIndex
. If i walk jnxBgpM2PeerIndex
it gives me the local/remote addresses as indexes and the peer index as value.
How do i join these two things so that the out prefix count is the value, and has local/remote addresses as labels? I have tried using lookups
but i think this only works if the thing you are looking up is an index, not a value?
My module config in generator.yml
looks like this:
(the overrides are needed to work around a bug in the way the addresses are sent from the device)
juniper_bgp_prefixes:
walk:
- jnxBgpM2PrefixOutPrefixes
- jnxBgpM2PeerIndex
- jnxBgpM2PeerLocalAddr
- jnxBgpM2PeerRemoteAddr
overrides:
jnxBgpM2PeerLocalAddr:
type: InetAddressMissingSize
jnxBgpM2PeerRemoteAddr:
type: InetAddressMissingSize
lookups:
- source_indexes: [jnxBgpM2PeerIndex]
lookup: jnxBgpM2PeerLocalAddr
- source_indexes: [jnxBgpM2PeerIndex]
lookup: jnxBgpM2PeerRemoteAddr
- source_indexes: [jnxBgpM2PeerIndex]
lookup: jnxBgpM2PeerRoutingInstance
An example output from this (addresses have been randomized):
# HELP jnxBgpM2PeerIndex This value is a unique index for the remote peer entry in the jnxBgpM2PeerTable - 1.3.6.1.4.1.2636.5.1.1.2.1.1.1.14
# TYPE jnxBgpM2PeerIndex gauge
jnxBgpM2PeerIndex{jnxBgpM2PeerLocalAddr="39.82.154.245",jnxBgpM2PeerRemoteAddr="39.82.154.244",jnxBgpM2PeerRoutingInstance="0"} 1
jnxBgpM2PeerIndex{jnxBgpM2PeerLocalAddr="2001:1234:0000:5000:0000:0000:0000:A5DF",jnxBgpM2PeerRemoteAddr="2001:1234:0000:5000:0000:0000:0000:A5DE",jnxBgpM2PeerRoutingInstance="0"} 3
jnxBgpM2PeerIndex{jnxBgpM2PeerLocalAddr="17.37.63.87",jnxBgpM2PeerRemoteAddr="17.37.63.86",jnxBgpM2PeerRoutingInstance="0"} 0
# HELP jnxBgpM2PeerLocalAddr The address of the local end of the peering session. - 1.3.6.1.4.1.2636.5.1.1.2.1.1.1.7
# TYPE jnxBgpM2PeerLocalAddr gauge
jnxBgpM2PeerLocalAddr{jnxBgpM2PeerLocalAddr="39.82.154.245",jnxBgpM2PeerRemoteAddr="39.82.154.244",jnxBgpM2PeerRoutingInstance="0"} 1
jnxBgpM2PeerLocalAddr{jnxBgpM2PeerLocalAddr="2001:1234:0000:5000:0000:0000:0000:A5DF",jnxBgpM2PeerRemoteAddr="2001:1234:0000:5000:0000:0000:0000:A5DE",jnxBgpM2PeerRoutingInstance="0"} 1
jnxBgpM2PeerLocalAddr{jnxBgpM2PeerLocalAddr="17.37.63.87",jnxBgpM2PeerRemoteAddr="17.37.63.86",jnxBgpM2PeerRoutingInstance="0"} 1
# HELP jnxBgpM2PeerRemoteAddr The address of the remote end of the peering session. - 1.3.6.1.4.1.2636.5.1.1.2.1.1.1.11
# TYPE jnxBgpM2PeerRemoteAddr gauge
jnxBgpM2PeerRemoteAddr{jnxBgpM2PeerLocalAddr="39.82.154.245",jnxBgpM2PeerRemoteAddr="39.82.154.244",jnxBgpM2PeerRoutingInstance="0"} 1
jnxBgpM2PeerRemoteAddr{jnxBgpM2PeerLocalAddr="2001:1234:0000:5000:0000:0000:0000:A5DF",jnxBgpM2PeerRemoteAddr="2001:1234:0000:5000:0000:0000:0000:A5DE",jnxBgpM2PeerRoutingInstance="0"} 1
jnxBgpM2PeerRemoteAddr{jnxBgpM2PeerLocalAddr="17.37.63.87",jnxBgpM2PeerRemoteAddr="17.37.63.86",jnxBgpM2PeerRoutingInstance="0"} 1
# HELP jnxBgpM2PrefixOutPrefixes The number of prefixes for a peer that are installed in that peers Adj-Ribs-Out. - 1.3.6.1.4.1.2636.5.1.1.2.6.2.1.10
# TYPE jnxBgpM2PrefixOutPrefixes gauge
jnxBgpM2PrefixOutPrefixes{jnxBgpM2PeerIndex="0",jnxBgpM2PeerLocalAddr="",jnxBgpM2PeerRemoteAddr="",jnxBgpM2PeerRoutingInstance="",jnxBgpM2PrefixCountersAfi="1",jnxBgpM2PrefixCountersSafi="1"} 7
jnxBgpM2PrefixOutPrefixes{jnxBgpM2PeerIndex="1",jnxBgpM2PeerLocalAddr="",jnxBgpM2PeerRemoteAddr="",jnxBgpM2PeerRoutingInstance="",jnxBgpM2PrefixCountersAfi="1",jnxBgpM2PrefixCountersSafi="1"} 7
jnxBgpM2PrefixOutPrefixes{jnxBgpM2PeerIndex="3",jnxBgpM2PeerLocalAddr="",jnxBgpM2PeerRemoteAddr="",jnxBgpM2PeerRoutingInstance="",jnxBgpM2PrefixCountersAfi="2",jnxBgpM2PrefixCountersSafi="1"} 4