feat(providers): add Nagios provider for monitoring host/service alerts#6403
Open
ayoubil wants to merge 1 commit intokeephq:mainfrom
Open
feat(providers): add Nagios provider for monitoring host/service alerts#6403ayoubil wants to merge 1 commit intokeephq:mainfrom
ayoubil wants to merge 1 commit intokeephq:mainfrom
Conversation
Adds an inbound webhook provider for Nagios Core/XI. Modeled after the existing Checkmk provider: a notification command on the Nagios server forwards the relevant NAGIOS_* environment macros to Keep's webhook endpoint, where NagiosProvider._format_alert maps both host and service notifications to AlertDto. - Supports PROBLEM, RECOVERY, ACKNOWLEDGEMENT, FLAPPINGSTART/STOP and DOWNTIMESTART/END notification types via STATUS_MAP. - Handles service states (OK/WARNING/CRITICAL/UNKNOWN) and host states (UP/DOWN/UNREACHABLE) via SEVERITIES_MAP, with RECOVERY explicitly mapped to INFO regardless of underlying state. - Parses Nagios timestamps in long, short and epoch formats; falls back to current UTC when missing/unparseable. - Stable id prefers $HOSTPROBLEMID$/$SERVICEPROBLEMID$ when available, otherwise host[/service]+timestamp. Closes keephq#3960
Author
|
/claim #3960 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements a Keep provider that ingests Nagios Core / Nagios XI notifications via webhook, modeled after the existing Checkmk provider (
keep/providers/checkmk_provider/).The Nagios server runs a small notification command (
webhook-keep.py) that forwards Nagios environment macros to Keep's webhook endpoint;NagiosProvider._format_alertthen maps the payload to anAlertDto.Changes
keep/providers/nagios_provider/__init__.py— package marker.keep/providers/nagios_provider/nagios_provider.py— main provider class.keep/providers/nagios_provider/alerts_mock.py— five mock notification payloads (service critical / host down / service recovery / acknowledgement / host recovery).keep/providers/nagios_provider/webhook-keep.py— installable Nagios notification script.Behaviour
AlertStatusviaSTATUS_MAP.AlertSeverityviaSEVERITIES_MAP. RECOVERY notifications are explicitly mapped to INFO regardless of the underlying state field._parse_timestamphandles$LONGDATETIME$,$SHORTDATETIME$(US, EU, ISO 8601date_formats) and epoch seconds; falls back to current UTC when missing / unparseable.$HOSTPROBLEMID$/$SERVICEPROBLEMID$when Nagios provides one, otherwisehost[/service]+timestampto keep alerts deduped across re-deliveries.Webhook script
The script reads
KEEP_WEBHOOK_URLandKEEP_API_KEYfrom the environment (set them via the Nagios command's argument macros), assembles a flat dict from theNAGIOS_*macros, and POSTs to Keep withX-API-KEY. Exit codes follow the convention of other Keep notification scripts (0 success, 1 transient error, 2 misconfiguration).How to verify
Spin up Nagios locally, drop
webhook-keep.pyonto the server, declare a notification command that runs it, and trigger a service problem (/etc/init.d/<svc> stop). The payload should appear in Keep with the correct status / severity / host / service fields. Mock payloads inalerts_mock.pymirror the production payload shape for unit-testing the mapping.Closes #3960