Monitor SNMP devices
Poll network devices, such as switches, routers, and firewalls, for system and per-interface metrics over SNMP, and write them to InfluxDB 3.
Configuration
[[inputs.snmp]]
## Devices to poll.
agents = ["udp://switch1.example.com:161", "udp://switch2.example.com:161"]
## SNMP version and community string.
version = 2
community = "public"
## Use the "source" tag for the device address, consistent with
## other plugins.
agent_host_tag = "source"
## Device-level values collected once per poll.
[[inputs.snmp.field]]
oid = "RFC1213-MIB::sysUpTime.0"
name = "uptime"
[[inputs.snmp.field]]
oid = "RFC1213-MIB::sysName.0"
name = "sysName"
is_tag = true
## Per-interface values collected from the interfaces table.
[[inputs.snmp.table]]
oid = "IF-MIB::ifTable"
name = "interface"
inherit_tags = ["sysName"]
## Tag rows by interface name.
[[inputs.snmp.table.field]]
oid = "IF-MIB::ifDescr"
name = "ifDescr"
is_tag = true
[[outputs.influxdb_v3]]
urls = ["http://localhost:8181"]
token = "AUTH_TOKEN"
database = "DATABASE_NAME"Replace the following:
AUTH_TOKEN: your InfluxDB authorization tokenDATABASE_NAME: the database to write to
Name-based OIDs like IF-MIB::ifTable require MIB files, which Telegraf
looks for in /usr/share/snmp/mibs by default.
On Debian and Ubuntu, install them with
sudo apt install snmp-mibs-downloader.
Without MIB files, use numeric OIDs instead, for example
oid = ".1.3.6.1.2.1.1.3.0" for sysUpTime.
How it works
agentslists the devices to poll. One plugin instance polls every agent with the same credentials and field definitions. Metrics carry asourcetag identifying the device.[[inputs.snmp.field]]entries read single (scalar) values.sysUpTimebecomes anuptimefield, andsysNamebecomes a tag on every metric from the device.[[inputs.snmp.table]]walks theIF-MIB::ifTableand produces one metric per table row, so each interface gets its owninterfacemetric with counters such asifInOctets,ifOutOctets, andifOperStatusas fields. TheifDescrcolumn is stored as a tag to identify the interface, andinherit_tagscopies the device-levelsysNametag onto each row.- For SNMPv3, replace
communitywith thesec_name,sec_level,auth_protocol, andpriv_protocoloptions from the plugin documentation, and keep passwords out of the config file with secret stores.
Example output
snmp,source=switch1.example.com,sysName=sw-core-01 uptime=1284923i 1709572230000000000
interface,ifDescr=GigabitEthernet0/1,source=switch1.example.com,sysName=sw-core-01 ifInOctets=918273645i,ifOutOctets=234981723i,ifOperStatus=1i,ifSpeed=1000000000i 1709572230000000000
interface,ifDescr=GigabitEthernet0/2,source=switch1.example.com,sysName=sw-core-01 ifInOctets=81723645i,ifOutOctets=34981723i,ifOperStatus=2i,ifSpeed=1000000000i 1709572230000000000Extend this example
- Interface octet counters are cumulative. Compute per-interval rates at query time, or use the derivative aggregator to emit rates directly.
- To collect only specific columns instead of the whole table, list them
as
[[inputs.snmp.table.field]]entries and remove the table walk of unneeded columns withindex_as_tagand column filters described in the plugin documentation. - Poll many devices efficiently by increasing
max_repetitionsfor bulk requests, and set per-pluginintervalto poll SNMP less often than your other inputs.
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for Telegraf and this documentation. To find support, use the following resources:
Customers with an annual or support contract can contact InfluxData Support.