Telegraf collecting snmp data from selected network interfaces

Hi,

I have set up telegraf to monitor my NAS through SNMP. Everything is working thus far. With this post I am looking for a way to make the setup more efficient.

The situation:

Telegraf is collecting data about all network interfaces with this entry in the telegraf config and writing the results to InfluxDB.

    [[inputs.snmp.table]]
        oid = "IF-MIB::ifXTable"

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

The problem:

Basically, I am interested in the network traffic data for the “eth0” and do not really care for other interfaces (maybe eth1, ovs_eth0/1 at some point). The real problem is that telegraf also collects network interface data for all docker containers. I have over 50 containers running on the machine and this is a waste of resources since I do not care for the data. And it makes the Grafana queries on ifXTable really sluggish.

The question:

Since I was not able to find some solution through google research: Is there a way to alter the above stated telegraf config entry to tell telegraf to only collect data from specific network interfaces?

Thanks!

There are 2 ways to achieve this:

  1. Continue to poll the whole table and use filtering to only send eth0 to influxdb
  2. Define which fields you want to poll (not in table) by using the complete index:
[[inputs.snmp.field]]
  name = "eth0_in_octets"
  oid = "IF-MIB::ifHCInOctets.0"
1 Like

@Hipska Thank you! That pointed me in the right direction.

I used approach 2, because it seemed better to only poll desired values instead of polling and then filtering.

I had to check for correct indexes first through snmpwalk on IF-MIB::ifName and then ended up with entries such as:

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

Beware of the downside of this, that the index for your interface might change after a restart of snmp agent or the device…

OK, thanks for the hint.