feat: add SNMP provider#6480
Conversation
|
Follow-up update based on pre-review cleanup:
|
digzrow-coder
left a comment
There was a problem hiding this comment.
There is a lifecycle bug in the default fingerprint/id. _stable_id() includes both trap_oid and generic_trap in the hashed payload, while linkDown maps to firing and linkUp maps to resolved. That means the recovery trap gets a different fingerprint from the outage trap:
- linkDown:
trap_oid=1.3.6.1.6.3.1.1.5.3,generic_trap=linkDown - linkUp:
trap_oid=1.3.6.1.6.3.1.1.5.4,generic_trap=linkUp
Since the provider then sets fingerprint=alert_id, Keep will ingest the linkUp as a separate resolved alert instead of resolving the existing linkDown alert for the same host/interface. The current tests only assert stable ids for identical payloads, so they miss the firing -> resolved pair.
For link state traps the fingerprint needs to be based on the resource identity (host + interface identity from varbinds, e.g. ifIndex/ifDescr/ifName) rather than the transition state. The trap type should drive status/severity, but it should not split the dedup key for the same resource.
Good spot on the fingerprint issue, you're right. Including generic_trap in the dedup key breaks the firing/resolved lifecycle for link state traps. |
|
N/A |
Closes #2112
/claim #2112
Summary
snmpprovider discovered by Keep's existing provider factory conventions.AlertDtoobjects with normalized host, source, status, severity, timestamps, stable IDs/fingerprints, labels, and structured SNMP details.snmp_varbindsand rawsnmp_eventfields for debugging and filtering.Why webhook-first
SNMP traps usually arrive over UDP, often on privileged port 162. Keeping this provider webhook-first avoids native listener lifecycle, threading, tenancy, container networking, and privileged-port complexity inside Keep. Operators can run standard trap receivers such as
snmptrapd,snmptt, Telegraf, or another relay to decode traps and forward JSON to/alerts/event/snmp.This intentionally does not add
pysnmp, SNMP polling, MIB parsing, SNMPv3 credential storage, or a native UDP listener.Validation
Passed:
Docs snippet generation:
wsl.exe bash -lc "cd '/mnt/c/Users/Dan/Documents/New project/keep' && /tmp/keep-snmp-venv/bin/python scripts/docs_render_provider_snippets.py"The committed
snmp-snippet-autogenerated.mdxwebhook section was produced by the repository script. The full--validatemode currently stops before completion on the existing main-branch indentation issue inkeep/providers/anthropic_provider/anthropic_provider.pyaround line 93.Attempted broader provider factory test:
wsl.exe bash -lc "cd '/mnt/c/Users/Dan/Documents/New project/keep' && /tmp/keep-snmp-venv/bin/python -m pytest tests/test_provider_factory.py -q"That run also fails before reaching SNMP because of the same unrelated existing
anthropic_providerindentation issue.GitHub Actions note: the larger PR workflows (
Unit Tests,Integration Tests,Test docs,Test workflow examples,Release JSON Schema,Tests (E2E)) currently showaction_requiredwith no jobs, meaning they are awaiting maintainer approval to run for this forked PR. The available checks (Validate PR title,Validate PR to Issue link, GitGuardian, CLA, CodeRabbit skip) pass.Demo Evidence
Demo video: Watch the MP4 demo
Executable formatter demo used the sample
linkDownpayload and produced:{ "name": "SNMP linkDown on 10.0.0.15", "host": "10.0.0.15", "source": ["snmp"], "status": "firing", "severity": "critical", "trap_oid": "1.3.6.1.6.3.1.1.5.3", "ifDescr": "eth0" }Reproduce against a running Keep API:
Expected result: a source
snmpalert for host10.0.0.15, statusfiring, severitycritical, withtrap_oidandifDescrvisible in alert details/labels.