Telegraf SNMP: Problem setting table measurement name / name_override also overriding table names

Hi folks,

I have problems to assign measurement names properly when using the SNMP plugin in combination with fields and tables at the same time.

Usually, for the fields, a single metric will be generated and snmp (plugin name) is used as measurement name. For tables, it also uses snmp but I can assign a different measurement name using the name config parameter like here:

[[inputs.snmp]]
...
  [[inputs.snmp.field]]
    oid = ".1.3.6.1.2.1.25.1.6.0"
    name = "numProcesses"

  [[inputs.snmp.table]]
    name = "hrProcessorLoad"
    [[inputs.snmp.table.field]]
      oid = "HOST-RESOURCES-MIB::hrProcessorLoad"

  [[inputs.snmp.table]]
    oid = "HOST-RESOURCES-MIB::hrStorageTable"
    name = "hrStorageTable"

I get those metrics:

snmp,agent_host=192.168.2.232,host=minion numProcesses=213i,sysUptime=807473.36 1736926680000000000
hrProcessorLoad,agent_host=192.168.2.232,host=minion influxdb_telegraf  | hrStorageTable,agent_host=192.168.2.232,host=minion,hrStorageIndex=5 
...
hrStorageTable,agent_host=192.168.2.232,host=minion,hrStorageIndex=6 hrStorageSize=624608i,hrStorageUsed=300333i,hrStorageAllocationFailures=0i,hrStorageType=".1.3.6.1.2.1.25.2.1.3",hrStorageDescr="Virtual Memory",hrStorageAllocationUnits=65536i 1736926680000000000
...

(I shortened the output/config a bit for readability)

That’s fine so far.

I need those unique measurement names for the table metrics because I want to filter the metrics to target separated Starlark processor plugins using namepass filter.

Now, I want to rename the measurement snmp to something else. The only way I have found for that is by using name_override globally:

[[inputs.snmp]]
...
  name_override = "machines"

  [[inputs.snmp.field]]
    oid = "RFC1213-MIB::sysUpTime.0"

  [[inputs.snmp.field]]
    oid = ".1.3.6.1.2.1.25.1.6.0"

  [[inputs.snmp.table]]
    name = "hrProcessorLoad"
    [[inputs.snmp.table.field]]
      oid = "HOST-RESOURCES-MIB::hrProcessorLoad"

  [[inputs.snmp.table]]
    oid = "HOST-RESOURCES-MIB::hrStorageTable"
    name = "hrStorageTable"

But doing so does not only override the measurement name for the field metrics but also overrides the measurement names of the table metrics resulting in this:

machines,agent_host=192.168.2.232,host=minion sysUptime=807593.36,numProcesses=215i 1736926800000000000
machines,agent_host=192.168.2.232,host=minion hrProcessorLoad=13i 1736926800000000000
...
machines,agent_host=192.168.2.232,host=minion,hrStorageIndex=5 hrStorageDescr="O:\\",hrStorageAllocationUnits=0i,hrStorageSize=0i,hrStorageUsed=0i,hrStorageAllocationFailures=0i,hrStorageType=".1.3.6.1.2.1.25.2.1.4" 1736926800000000000
...

Basically, the name parameter in the tables is ignored now. So, it is not possible anymore to distinguish different metrics in Starlark processor plugins using the namepass parameter.

So, the question is: is it intended behavior that name_override also overrides all the table measurement names that were explicitly set in the tables?
If yes, is there another way to assign a custom measurement name for the field metric and, at the same time, different custom measurement names for the table metrics?

Thanks alot!

Keep using SNMP as the name (or set a custom one) and then use processor.override combined with selectors (namepass for this case)

[[processors.override]]
  namepass = ["snmp"]
  name_override = "machines"

this will apply the logic only to a subset of your points (filtered by measurement)

Works fine, thanks a lot!
In case of having multiple snmp plugins: is it possible to distinguish between them and have different name_override for them?
My only idea would be to give each plugin an additional “fake” tag and use one override plugin per snmp plugin and use in tagpass to distinguish the different snmp plugins.

My only idea would be to give each plugin an additional “fake” tag and use one override plugin per snmp plugin and use in tagpass to distinguish the different snmp plugins.

That’s correct

1 Like

Just use

[[inputs.snmp]]
...
  name = "machines"
1 Like

Interesting, is there documentation about what it does?

It does not seem to be listed here:

And I also cannot find a parameter name anywhere else on that page.

Its indeed not documented, but it’s defined here: telegraf/plugins/inputs/snmp/snmp.go at e57f48f608be769b17649b44a15bcc591fb6267a · influxdata/telegraf · GitHub

2 Likes

Okay thanks alot, that’s interesting, will look into that!

Okay, that’s awesome, name gives a new measurement name to the plugin but still allows using name in tables to assign specific names for table measurements (unlike name_override).