telegraf icon indicating copy to clipboard operation
telegraf copied to clipboard

[processors.snmp_lookup] Add support for non-indexed values (e.g. sysName)

Open bbczeuz opened this issue 5 months ago • 3 comments

Use Case

I want to add RFC1213-MIB::sysUpTime.0 as tag to metrics. (e.g. network interface traffic, printer supplies,...). Can we make the index_tag value optional and if it's not defined by the configuration, the value is applied to all metrics of the agent_tag?

Expected behavior

Using this configuration:

[[inputs.snmp]]
  agents = ["udp://10.20.30.40:161"  ]
  name_override = "printers"

  [[inputs.snmp.table]]
    oid = "Printer-MIB::prtMarkerSuppliesTable"
    [[inputs.snmp.table.field]]
      oid = "Printer-MIB::prtMarkerSuppliesDescription"
      is_tag = true

[[processors.snmp_lookup]]
  agent_tag = "agent_host"
  namepass = ["printers"]
  [[processors.snmp_lookup.tag]]
    oid = "RFC1213-MIB::sysName.0"
    name = "sysName"

I expect results like:

printers,agent_host=10.20.30.40,some_more_tags=foo,prtMarkerSuppliesDescription=foo,sysName=pri-somewhere some_fields=123i,prtMarkerSuppliesColorantIndex=2i,prtMarkerSuppliesLevel=31i 1751993506000000000
printers,agent_host=10.20.30.40,some_more_tags=foo,prtMarkerSuppliesDescription=bar,sysName=pri-somewhere some_fields=123i,prtMarkerSuppliesColorantIndex=3i,prtMarkerSuppliesLevel=31i 1751993506000000000
printers,agent_host=10.20.30.40,some_more_tags=foo,prtMarkerSuppliesDescription=baz,sysName=pri-somewhere some_fields=123i,prtMarkerSuppliesColorantIndex=4i,prtMarkerSuppliesLevel=31i 1751993506000000000

I tried to add sysName as separate fields to the inputs.snmp plugin, but then I receive two results (one with sysName and some dummy field and one with the data) that I later have to join somehow (aggregators.merge can't join on tags)

Actual behavior

the processors.snmp_lookup plugin doesn't accept the configuration.

Additional info

No response

bbczeuz avatar Jul 08 '25 17:07 bbczeuz

This can be achieved by using the inherit_tags option on the table.

Hipska avatar Nov 07 '25 18:11 Hipska

That works perfectly for my use case. Unfortunately, the option is hidden in an example config. Doc enhancement?

bbczeuz avatar Nov 09 '25 23:11 bbczeuz

Feel free to make a PR with your enhancements.

Hipska avatar Nov 10 '25 06:11 Hipska