#19816·telegraf

inputs.snmp: SNMPv3 polling never recovers after the agent restarts with a new engine ID

Author: SalvoraCreated Sep 30, 2026Updated Sep 30, 2026
Labelsbug

Relevant telegraf.conf

toml
[[inputs.snmp]]
  agents = ["udp://192.0.2.5:161"]
  version = 3
  sec_level = "authPriv"
  sec_name = "<user>"
  auth_protocol = "SHA"
  auth_password = "<secret>"
  priv_protocol = "AES"
  priv_password = "<secret>"
  interval = "60s"
  timeout = "10s"
  retries = 1

  [[inputs.snmp.field]]
    name = "device"
    oid = ".1.3.6.1.2.1.1.5.0"
    is_tag = true
  [[inputs.snmp.field]]
    name = "uptime"
    oid = ".1.3.6.1.2.1.1.3.0"

Logs from Telegraf

2026-09-30T18:52:21Z E! [inputs.snmp] Error in plugin: agent udp://192.0.2.5:161: performing get on field device: request timeout (after 1 retries)
(agent rebooting)
2026-09-30T18:56:00Z E! [inputs.snmp] Error in plugin: agent udp://192.0.2.5:161: performing get on field device: incoming packet is not authentic, discarding
(repeats on every gather until Telegraf is restarted)

System info

Telegraf 1.40.1 (gosnmp v1.44.0), Debian 13 host

Docker

Official Telegraf image on a user-defined bridge network. Nothing Docker-specific in the failure.

Steps to reproduce

1 .Poll an SNMPv3 authPriv agent whose engine ID changes when it restarts. The UniFi U7 Pro XG Wall (8.7.11) generates a new engine ID on every boot. 2. Reboot the agent and wait for it to come back. 3. ...

Expected behavior

Telegraf rediscovers the agent's engine ID and polling resumes, as it does for a freshly started Telegraf or for snmpget.

Actual behavior

Every gather fails with "incoming packet is not authentic, discarding" indefinitely. Restarting Telegraf fixes it immediately. Seen three times in one week, once per AP reboot.

Additional info

Capture on the Telegraf host during the failure:

TELEGRAF > AGENT.161: { SNMPv3 { F=apr } { USM B=1 T=98072 U="<user>" } { ScopedPDU [encrypted] } }
AGENT.161 > TELEGRAF: { SNMPv3 { F= } { USM B=1 T=11385 U="<user>" } { ScopedPDU E=_80_00_1f_88_80_be_21_4d_13_97_e4_4e_6a_00_00_00_00 C="" { Report(29) R=0  .1.3.6.1.6.3.15.1.1.4.0=1497 } } }

The agent answers every request with an unauthenticated usmStatsUnknownEngineIDs REPORT. The session is still using the agent's pre-reboot engine ID and engine time (T=98072; the agent now reports B=1, T=11385). Sending that REPORT unauthenticated is standard behaviour; net-snmp's snmpv3_make_report does the same.

Then:

  • getConnection() in plugins/inputs/snmp/snmp.go reuses the cached connection for an agent indefinitely, and GosnmpWrapper.Reconnect() only reconnects when Conn == nil. The USM state from the first engine discovery is never refreshed.
  • gosnmp (v1.44.0 and current master) checks every reply against the session's configured security level (testAuthentication in v3.go). The unsigned REPORT is rejected as "not authentic" before its REPORT handling can update the engine ID. This is tracked in gosnmp/gosnmp#601. Under the plan there, a mismatched engine ID on an established session becomes an explicit error rather than being adopted, so recovery has to come from the caller.

For SNMPv3 agents, when a gather fails, close and drop the cached connection (connectionCache[idx] = nil) so the next interval runs a fresh engine discovery. That is what a Telegraf restart does today.