Telegraf snmp - multiple fields with different tags

Objective: collect multiple specific snmp OIDs that have the same name, but with different tags.

For example, get the interface description and then the in and out octets for an interface. In the configuration below, only one of these outputs to influxdb (I suspect because they’re overwriting each other).

How is it possible to poll multiple values which have the same name, but with different tags?

[[inputs.snmp.field]]
name = "hostname"
oid = "RFC1213-MIB::sysName.0"
is_tag = true

[[inputs.snmp.field]]
name = "ifDescr"
oid = "IF-MIB::ifDescr.683"
is_tag = true

[[inputs.snmp.field]]
name = "ifHCInOctets"
oid = "IF-MIB::ifHCInOctets.683"

[[inputs.snmp.field]]
name = "ifHCOutOctets"
oid = "IF-MIB::ifHCOutOctets.683"

[[inputs.snmp.field]]
name = "ifDescr"
oid = "IF-MIB::ifDescr.635"
is_tag = true

[[inputs.snmp.field]]
name = "ifHCInOctets"
oid = "IF-MIB::ifHCInOctets.635"

[[inputs.snmp.field]]
name = "ifHCOutOctets"
oid = "IF-MIB::ifHCOutOctets.635"

debug:
> network-interfaces,agent_host=1.2.3.4,host=node.domain.tld,hostname=device.host.name,ifDescr=xe-0/0/19 ifHCInOctets=10398374903i,ifHCOutOctets=571882926i 1565784776000000000

Thanks

Hi @amf ,

I think by using multiple
[[inputs.snmp]] section …

[[inputs.snmp]]
[[inputs.snmp.field]]
name = “hostname”
oid = “RFC1213-MIB::sysName.0”
is_tag = true

[[inputs.snmp.field]]
name = “ifDescr”
oid = “IF-MIB::ifDescr.683”
is_tag = true

[[inputs.snmp.field]]
name = “ifHCInOctets”
oid = “IF-MIB::ifHCInOctets.683”

[[inputs.snmp.field]]
name = “ifHCOutOctets”
oid = “IF-MIB::ifHCOutOctets.683”

[[inputs.snmp]]
[[inputs.snmp.field]]
name = “ifDescr”
oid = “IF-MIB::ifDescr.635”
is_tag = true

[[inputs.snmp.field]]
name = “ifHCInOctets”
oid = “IF-MIB::ifHCInOctets.635”

[[inputs.snmp.field]]
name = “ifHCOutOctets”
oid = “IF-MIB::ifHCOutOctets.635”

What I think you want to do here is use the table functionality, for each item in the table a metric will be created tagged by the index. You can use table fields to modify the names and tag status of specific entries. All fields in the table are always collected, but if you don’t want a specific entry you can use fielddrop (or tagdrop for excluding certain interfaces):

[[inputs.snmp]]

  fielddrop = ["ifPhysAddress"]

  [[inputs.snmp.field]]
    name = "hostname"
    oid = "RFC1213-MIB::sysName.0"
    is_tag = true

  [[inputs.snmp.table]]
    name = "interface"
    oid = "IF-MIB::ifTable"
    inherit_tags = ["hostname"]

    [[inputs.snmp.table.field]]
      oid = "IF-MIB::ifDescr"
      is_tag = true

If you have lots of interfaces and only want a very small number of OIDs collected, then @MarcV’s suggestion might work better.

Thanks for your replies @MarcV and @daniel !

I did consider the multiple [[inputs.snmp]], but I believe this would also require duplicating all the values in that section, eg. my base [[inputs.snmp]] looks like this:

[[inputs.snmp]]
  agents = [ "1.2.3.4" ]
  interval = "60s"
  timeout = "30s"
  retries = 2
  version = 2
  community = "mycommunity"
  max_repetitions = 10

Unless I’m misunderstanding, each of these would need to be defined in each of the [[inputs.snmp]], is that correct? (nb. these are unique to the polling I’m trying to configure, they’re not global)

For the table functionality, I believe this will walk the tables in full (both ifTable and ifDescr) and store all except those configred by fielddrop/tagdrop? The problem here, and what I was trying to avoid, is excessive polling. Some devices (hey, looking at you Juniper) really don’t like this, and it causes excessive RE load.

Thanks for the help :slight_smile: