Overview
Integrating Nagios with SPOG.AI enables centralized monitoring and streamlined incident management. This integration involves configuring Nagios to send alerts to SPOG.AI via webhooks.
Key Features
| Capability | Description |
| Webhook Alert Delivery | Nagios sends alerts to SPOG.AI through webhook POST requests. |
| Host & Service Notifications | Nagios triggers notifications on host or service state changes, which are delivered to SPOG.AI. |
| JSON Payloads | Notification commands send JSON payloads with relevant alert fields (hostname, state, service, output, etc.). |
| Incident Mapping & CMDB Enrichment | SPOG.AI maps incoming webhooks to incidents or enriches them with CMDB context. |
| Unified Dashboards & Correlation | Provides unified dashboards, alert correlation, and incident workflows. |
| Recovery Alerts | Receives recovery / resolved alerts, depending on Nagios notification settings. |
| Centralized Monitoring | Enables centralized monitoring and streamlined incident management. |
How the Integration Works
Nagios triggers notifications on host or service state changes. Notification commands (via curl or HTTP client) are defined to make a webhook POST to a SPOG.AI endpoint, sending JSON payloads with relevant alert fields (hostname, state, service, output, etc.).
SPOG.AI ingests these webhooks, maps them to incidents or enriches them with CMDB context, and provides unified dashboards, alert correlation, and incident workflows.
Data Collected
When integrated, you can expect SPOG.AI to receive:
| Category | Data Collected | Description |
| Host Alerts | Host name, state (UP, DOWN, UNREACHABLE), output / message | Alerts raised for host state changes. |
| Service Alerts | Host name, service description, state (OK, WARNING, CRITICAL), output | Alerts raised for service state changes. |
| Timestamps & Macro Fields | Timestamps, macro fields (e.g. $SHORTDATETIME$, $NOTIFICATIONTYPE$, etc.) | Time and notification details supplied by Nagios macros. |
| Recovery Alerts | Recovery / resolved alerts, depending on Nagios notification settings | Alerts indicating a host or service has recovered. |
| Correlation & Filtering | Correlation / filtering capabilities in SPOG to group related alerts | Grouping of related alerts within SPOG.AI. |
Prerequisites
Before configuring the integration, ensure the following prerequisites are met:
- You must have Admin / Tenant Admin privileges in SPOG.AI to configure the integration.
- You have access to modify your Nagios configuration (Nagios Core, Nagios XI, or equivalent), specifically commands, contacts, and host/service definitions.
- Nagios notification logic (host/service notifications) must be enabled.
- The SPOG webhook endpoint (URL) must be reachable from the Nagios server(s).
- You understand Nagios’ notification and macro system (Nagios supports macros in commands).
- Some familiarity with Nagios’ event handler and notification timing logic is useful (Nagios sends notifications on state changes / intervals).
Configuration
1. Generate Connection Details
Obtain SPOG Webhook URL
- In SPOG.AI: go to Settings → Integrations → Add Integration.
- Select Nagios / Monitoring Integration, click Configure.
- SPOG will generate a Webhook Endpoint URL (e.g. https://spog.example.com/webhook/nagios)
- Copy and securely store this URL (it’s the destination Nagios will call).
2. Configure Nagios in SPOG
Step 1: Create Webhook Notification Commands
- In Nagios configuration (commands.cfg or via UI in Nagios XI), define commands that use curl or a similar HTTP client to POST JSON payloads to the SPOG webhook.
Example definitions:
| define command { command_name notify-host-by-webhook command_line /usr/bin/curl -X POST -H ‘Content-Type: application/json’ \ -d ‘{“host”:”$HOSTNAME$”,”state”:”$HOSTSTATE$”,”output”:”$HOSTOUTPUT$”}’ \ https://webhook.spog.ai/your-endpoint } define command { command_name notify-service-by-webhook command_line /usr/bin/curl -X POST -H ‘Content-Type: application/json’ \ -d ‘{“host”:”$HOSTNAME$”,”service”:”$SERVICEDESC$”,”state”:”$SERVICESTATE$”,”output”:”$SERVICEOUTPUT$”}’ \ https://webhook.spog.ai/your-endpoint } |
- Be sure to escape quoting and handle special characters if needed.
Step 2: Create a Contact for Webhook Notifications
In Nagios contacts definitions:
| define contact { contact_name webhook_contact service_notification_period 24×7 host_notification_period 24×7 service_notification_options w,u,c,r host_notification_options d,u,r service_notification_commands notify-service-by-webhook host_notification_commands notify-host-by-webhook } |
- In Nagios XI, you can do this via Core Config Manager → Contacts UI.
Step 3: Assign Contact to Contact Groups
- Edit or create a contact group (e.g. webhook_group) and add webhook_contact as a member.
- This ensures notifications to that group trigger webhook commands.
Step 4: Assign Contact / Contact Group to Hosts & Services
In the host and service definitions, include:
| contacts webhook_contact contact_groups webhook_group |
- Or assign the contact group you created above.
Step 5: (Optional) Use Notification / Event Handler Settings
- Ensure the host/service has notification options enabled (for warning, critical, recoveries) and within notification periods.
- Nagios will only send notifications when the notification filters are satisfied (e.g. not in downtime, not flapping).
Step 6: Restart / Reload Nagios
- Save configuration changes, check configuration validity (/usr/local/nagios/bin/nagios -v /etc/nagios/nagios.cfg or equivalent).
- Restart or reload Nagios:
| sudo systemctl restart nagios |
- (or service nagios reload, etc.)
3. Security & Access Control
- Protect the SPOG webhook endpoint — ensure it uses HTTPS and optionally expects an authorization header / token.
- On Nagios side, run curl under a user with limited privileges (Nagios’ account).
- Be cautious with shell quoting / injection vulnerabilities in command definitions.
- Validate payloads on SPOG side (e.g. HMAC signature, IP allowlist).
- Use firewall / ACL rules to allow only your Nagios server(s) to call the webhook.
- Limit the contact / webhook configuration changes to authorized operators only.
- Log webhook calls and responses (success / failure) on SPOG side for audit.
4. Network & Connectivity
- The Nagios server must reach the SPOG webhook URL over HTTPS (port 443).
- Ensure firewalls, proxies or NAT do not strip or tamper with HTTP headers (especially JSON body).
- If the webhook is behind NAT / load balancer, ensure DNS / SSL resolution is correct from Nagios host.
- Set appropriate HTTP timeouts in curl (e.g. –max-time 10) to avoid hanging Nagios notifications.
5. Validation & Testing
- Use Nagios UI or force a test notification (e.g. via a forced event) and verify that SPOG receives the JSON payload.
- Use manual cURL to test:
| curl -X POST -H ‘Content-Type: application/json’ \ -d ‘{“test”:”nagios”}’ https://webhook.spog.ai/your-endpoint |
- Check Nagios logs (e.g. nagios.log) for errors or failed notification commands.
- Inspect SPOG’s logs or dashboard to confirm ingestion of alerts.
- Simulate both host and service alerts to test both command paths.
- Check edge cases: notifications suppressed (in downtime), recoveries, multiple alerts in quick succession.
Uninstalling the Integration
- In SPOG.AI, remove the Nagios integration entry.
- In Nagios configuration:
- 1. Remove the custom commands (notify-host-by-webhook, notify-service-by-webhook).
- 2. Remove contact definitions and contact groups referencing the webhook.
- 3. Remove references to that contact / group in host and service definitions.
- Reload or restart Nagios to apply changes.
- Confirm no further webhook POSTs are sent to SPOG.