Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat(providers): add Nagios provider for monitoring host/service alerts#6403

Open
ayoubil wants to merge 1 commit intokeephq:mainkeephq/keep:mainfrom
ayoubil:nagios-providerayoubil/keep:nagios-providerCopy head branch name to clipboard
Open

feat(providers): add Nagios provider for monitoring host/service alerts#6403
ayoubil wants to merge 1 commit intokeephq:mainkeephq/keep:mainfrom
ayoubil:nagios-providerayoubil/keep:nagios-providerCopy head branch name to clipboard

Conversation

@ayoubil
Copy link
Copy Markdown

@ayoubil ayoubil commented May 5, 2026

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_alert then maps the payload to an AlertDto.

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

  • Notification types: PROBLEM, RECOVERY, ACKNOWLEDGEMENT, FLAPPINGSTART/STOP/DISABLED, DOWNTIMESTART/END/CANCELLED, CUSTOM. Each maps to an appropriate AlertStatus via STATUS_MAP.
  • States: service states (OK / WARNING / CRITICAL / UNKNOWN) and host states (UP / DOWN / UNREACHABLE) are mapped to AlertSeverity via SEVERITIES_MAP. RECOVERY notifications are explicitly mapped to INFO regardless of the underlying state field.
  • Timestamps: _parse_timestamp handles $LONGDATETIME$, $SHORTDATETIME$ (US, EU, ISO 8601 date_formats) and epoch seconds; falls back to current UTC when missing / unparseable.
  • Stable id: prefers $HOSTPROBLEMID$ / $SERVICEPROBLEMID$ when Nagios provides one, otherwise host[/service]+timestamp to keep alerts deduped across re-deliveries.

Webhook script

The script reads KEEP_WEBHOOK_URL and KEEP_API_KEY from the environment (set them via the Nagios command's argument macros), assembles a flat dict from the NAGIOS_* macros, and POSTs to Keep with X-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.py onto 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 in alerts_mock.py mirror the production payload shape for unit-testing the mapping.

Closes #3960

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
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label May 5, 2026
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 5, 2026

CLA assistant check
All committers have signed the CLA.

@dosubot dosubot Bot added Feature A new feature Provider Providers related issues labels May 5, 2026
@ayoubil
Copy link
Copy Markdown
Author

ayoubil commented May 5, 2026

/claim #3960

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]: Nagios Provider

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.