Using Prometheus with SNMP Exporter and regex to format OctetStrings

We running Prometheus with SNMP Exporter to scrape SNMP targets. One target uses a large number of OctetStrings. What we'd like to achieve is overriding the OctetStrings to DisplayStrings and then using regex to retrieve the label as the metric.

The MIB looks as follows: The MIB file

For now we'll only focus on cfgProductName, cfgSoftwareVersion and cfgMIBVersion.

  • For cfgProductName we'll add overrides for the type from OctetString to DisplayString and a regex to return the label value of cfgProductName as the metric. The regex we used is adapted from the Grafana regex use here and tested on regex101. We confirmed that the regex yields the result we're after.
  • For cfgSoftwareVersion we'll add overrides for the type from OctetString to DisplayString and a simple regex just to test that the regex is doing something.
  • For cfgMIBVersion we just change type from OctetString to DisplayString with no regex.

Our generator.yml file looks as follows: The generator.yml file

The resulting SNMP.yml looks as follows: The SNMP.yml file

We use the resulting SNMP.yml in the SNMP Exporter to scrape the target.

The results are as follows:

  • For cfgProductName, Prometheus allows autocomplete of the search string indicating that the scrape is in the DB, but returns an empty query result.
  • For cfgSoftwareVersion, Prometheus doesn't allow autocomplete of the search string, suggesting that no scrape was performed.
  • For cfgMIBVersion, the OctetString is changed to a DisplayString as we expected and Prometheus returns a result.cfgMIBVersion query result

We were expecting to see e.g. cfgProductNameValue with a metric equal to the result of the regex. Any suggestions on where we're going wrong?

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum