1

I'm collecting interface statistics from some switches using the following configuration:

modules:
  if_mib:
    walk:
      - ifTable
    auth:
      community: monitor

The data returned from the exporter is indexed by ifIndex. That is, a query for ifInOctets{instance="192.168.1.1"} results in:

ifInOctets{ifIndex="1",instance="192.168.1.1",job="snmp_if"}    129355
ifInOctets{ifIndex="2",instance="192.168.1.1",job="snmp_if"}    359870890
ifInOctets{ifIndex="3",instance="192.168.1.1",job="snmp_if"}    0
ifInOctets{ifIndex="4",instance="192.168.1.1",job="snmp_if"}    212586200

Etc. I want the interface names for display purposes, which I can get with the following query:

ifInOctets{instance="192.168.1.1"} * ignoring(ifDescr) group_left(ifDescr) ifDescr

Which returns:

{ifDescr="lo",ifIndex="1",instance="192.168.1.1",job="snmp_if"} 129355
{ifDescr="itf0",ifIndex="2",instance="192.168.1.1",job="snmp_if"}   359870890
{ifDescr="imq0",ifIndex="3",instance="192.168.1.1",job="snmp_if"}   0
{ifDescr="eth0",ifIndex="4",instance="192.168.1.1",job="snmp_if"}   2125862004

How can I filter the results by the value of the ifDescr attribute?

I tried the following, expecting it to fail, and indeed I was not surprised:

ifInOctets{instance="192.168.1.1", ifDescr="eth0"} * ignoring(ifDescr) group_left(ifDescr) ifDescr
larsks
  • 41,276
  • 13
  • 117
  • 170

1 Answers1

0

I figured it out, but rather than deleting the question I thought someone else might find this useful. The answer is:

ifInOctets{instance="192.168.1.1"} * ignoring(ifDescr) group_left(ifDescr) ifDescr{ifDescr="eth0"}

I found this article helpful in understand the query syntax. In particular, this highlighted that the above expression is:

<series1> * <series2>

...which made it more obvious that standard selectors can be applied to the second series.

larsks
  • 41,276
  • 13
  • 117
  • 170