Skip to content

feat: add SNMP webhook provider#6275

Open
Lumantis wants to merge 1 commit intokeephq:mainfrom
Lumantis:bounty/2112-snmp-provider
Open

feat: add SNMP webhook provider#6275
Lumantis wants to merge 1 commit intokeephq:mainfrom
Lumantis:bounty/2112-snmp-provider

Conversation

@Lumantis
Copy link
Copy Markdown

Closes #2112

What this adds

An SNMP provider that ingests trap data via webhook — same zero-dependency pattern as the Checkmk, Wazuh, and Netdata providers.

An SNMP manager (snmptrapd, Net-SNMP, Zabbix, or any custom handler) formats trap data as JSON and POSTs it to Keep's webhook endpoint. No pysnmp, no easysnmp, no external SNMP library on Keep's side.

Files

File Purpose
keep/providers/snmp_provider/snmp_provider.py Provider implementation
keep/providers/snmp_provider/alerts_mock.py Mock payload for UI preview
tests/providers/snmp_provider/test_snmp_provider.py 18 unit tests

Behaviour

All 7 RFC 1157 generic trap types handled:

Trap type Name Severity Status
0 coldStart WARNING FIRING
1 warmStart INFO FIRING
2 linkDown CRITICAL FIRING
3 linkUp INFO RESOLVED
4 authenticationFailure HIGH FIRING
5 egpNeighborLoss WARNING FIRING
6 enterpriseSpecific INFO FIRING

Field aliasing — accepts both snake_case and camelCase variants (agent_addr / agentAddr, trap_type / trapType, etc.) for compatibility with different trap forwarders.

Varbind extraction — OID, type, and value included in the alert description.

Example payload

{
  "agent_addr": "192.168.1.10",
  "trap_type": 2,
  "trap_name": "linkDown",
  "enterprise": "1.3.6.1.2.1.11",
  "uptime": "123456",
  "timestamp": "2024-10-26T23:20:39+00:00",
  "community": "public",
  "varbinds": [
    {"oid": "1.3.6.1.2.1.2.2.1.1.1", "type": "integer", "value": "1"},
    {"oid": "1.3.6.1.2.1.2.2.1.2.1", "type": "octet-string", "value": "eth0"}
  ]
}

Why webhook-based, no pysnmp

Adding pysnmp (or any SNMP library) means Keep would need to open a UDP port, manage its own trap receiver, handle SNMPv1/v2c/v3 auth, and deal with ASN.1 decoding. All of that complexity lives in the user's existing SNMP infrastructure already. The webhook model lets any trap daemon do the heavy lifting and push clean JSON — the same pattern Checkmk, Wazuh, and Netdata use.

Adds an SNMP provider that receives trap data via webhook, using the
same zero-dependency pattern as the Checkmk, Wazuh, and Netdata providers.
An SNMP manager (snmptrapd, Net-SNMP, Zabbix, etc.) posts trap data as
JSON to Keep's webhook endpoint — no pysnmp or other SNMP library needed.

- Maps all 7 RFC 1157 generic trap types to AlertSeverity/AlertStatus
  (linkDown → CRITICAL/FIRING, linkUp → INFO/RESOLVED, etc.)
- Extracts varbinds, OIDs, agent address, enterprise OID, community string
- Accepts both camelCase and snake_case field names for interoperability
- Includes alerts_mock.py and a full pytest suite covering all trap types,
  field aliases, varbind formatting, and edge cases

Closes keephq#2112
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Apr 21, 2026
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 21, 2026

CLA assistant check
All committers have signed the CLA.

@dosubot dosubot Bot added Feature A new feature Provider Providers related issues labels Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature A new feature Provider Providers related issues size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🔌 Provider]: SNMP provider

2 participants