docs/netdata-ai/skills/query-snmp-traps/how-tos/top-trap-senders-last-hour.md
Which source devices sent the most SNMP traps in the last hour?
NODE_UUID: node running the snmp_traps collector.SNMP_TRAPS_JOB: trap listener job name. Default examples use local.LAST_SECONDS, defaulting to 3600.Load the token-safe wrappers:
source "$(git rev-parse --show-toplevel)/docs/netdata-ai/skills/query-netdata-agents/scripts/_lib.sh"
agents_load_env
Request source facets for recent trap entries:
NODE_UUID="YOUR_NODE_UUID"
SNMP_TRAPS_JOB="local"
SNMP_TRAPS_FUNCTION="snmp:traps"
LAST_SECONDS=3600
BODY="$(jq -n --arg job "$SNMP_TRAPS_JOB" --argjson last_seconds "$LAST_SECONDS" '{
after: (0 - $last_seconds),
before: 0,
last: 50,
direction: "backward",
selections: {
__logs_sources: [$job],
TRAP_REPORT_TYPE: ["trap"]
},
facets: ["TRAP_SOURCE_IP", "_HOSTNAME", "TRAP_DEVICE_VENDOR", "TRAP_SEVERITY"]
}')"
mkdir -p .local/audits/query-snmp-traps
agents_call_function \
--via cloud \
--node "$NODE_UUID" \
--function "$SNMP_TRAPS_FUNCTION" \
--body "$BODY" \
> .local/audits/query-snmp-traps/top-senders.json
Print the top source-IP facet values without exposing them in a durable report:
jq '
.facets[]?
| select((.id // .name) == "TRAP_SOURCE_IP")
| .options
| sort_by(-(.count // 0))
| .[:20]
| map({source_ip: (.id // .name), count})
' .local/audits/query-snmp-traps/top-senders.json
If hostnames are available, inspect the _HOSTNAME facet too:
jq '
.facets[]?
| select((.id // .name) == "_HOSTNAME")
| .options
| sort_by(-(.count // 0))
| .[:20]
| map({hostname: (.id // .name), count})
' .local/audits/query-snmp-traps/top-senders.json
Return the top sender counts. In durable artifacts, redact or summarize source identities unless they are local/private examples.
TRAP_SOURCE_IP is usually the most reliable sender key because
traps arrive over UDP._HOSTNAME is better when identity correlation from SNMP/topology
is available.TRAP_REPORT_TYPE=deduplication_summary to inspect suppression.