snmp_exporter icon indicating copy to clipboard operation
snmp_exporter copied to clipboard

Lookups with different destination index names from source_indexes names? (ifIndex values, but under different name)

Open frittentheke opened this issue 2 years ago • 1 comments

I used the search function some, but could not find an answer to a problem I ran into:

Apparently some MIBs reuse the values of e.g. the popular ifIndex (IF-MIB), but under a different name. Exhibit A(rista):

In their ARISTA-IP-MIB (https://www.arista.com/assets/data/docs/MIBS/ARISTA-IP-MIB.txt) the index aristaIpIfStatsIfIndex is defined with:

[...] aristaIpIfStatsIfIndex OBJECT-TYPE SYNTAX InterfaceIndex MAX-ACCESS not-accessible STATUS current DESCRIPTION "The index value that uniquely identifies the interface to which this entry is applicable. The interface identified by a particular value of this index is the same interface as identified by the same value of the IF-MIB's ifIndex." ::= { aristaIpIfStatsEntry 2 } [...]

So the snmp_exporter produces metrics like:

[...]
# HELP aristaIpIfStatsOutUcastPkts The number of IP unicast packets transmitted - 1.3.6.1.4.1.30065.3.27.1.1.1.9                                                                                                   
# TYPE aristaIpIfStatsOutUcastPkts counter                                                                                                                                                                         
aristaIpIfStatsOutUcastPkts{aristaIpIfStatsIPVersion="1",aristaIpIfStatsIfIndex="1000001"} 0                                                                                                                       
aristaIpIfStatsOutUcastPkts{aristaIpIfStatsIPVersion="1",aristaIpIfStatsIfIndex="1000002"} 0                                                                                                                       
aristaIpIfStatsOutUcastPkts{aristaIpIfStatsIPVersion="1",aristaIpIfStatsIfIndex="10001"} 0                                                                                                                         
aristaIpIfStatsOutUcastPkts{aristaIpIfStatsIPVersion="1",aristaIpIfStatsIfIndex="1000501"} 0     
[...]

Just like it's common for IF-MIB tables, I would like to lookup and add the ifName or ifAlias labels here. But as far as I understand the config of the generator's lookups (https://github.com/prometheus/snmp_exporter/blob/323d1b08578527d9ba0cdea7846c61942bb85e42/generator/generator.yml#L12C1-L12C1) functionality, the index defined by source_indexes has to exist under the same name in the table which fields are "joined"?

So my question are:

  • Can this be done with the current capabilities of the generator?
  • If not, would you add (or accept a PR) allowing to configure a different index field name than used for the source (in cases where the same values are actually used).

frittentheke avatar Nov 20 '23 11:11 frittentheke

I don't remember a way to do this currently, but I think this would be useful feature.

SuperQ avatar Nov 20 '23 14:11 SuperQ