Skip to main content

A framework for event handlers for OMD

Project description

eventhandler

The eventhandler framework provides a flexible system for executing automated actions in response to monitoring events. Similar to notificationforwarder, it uses a modular architecture with runners, deciders, and formatters to handle event-driven automation tasks.

Loggers

The framework uses a modular logging architecture similar to runners, deciders, and formatters. By default, eventhandler uses text format logging - you don't need to do anything, logging works exactly as it did before. The traditional text format is backward compatible with all existing installations.

Why JSON Logging?

In enterprise environments, the gateway from monitoring systems to incident management platforms like Remedy, ServiceNow, or other ITSM tools is crucial for operational reliability. For comprehensive monitoring and troubleshooting of this critical path, logs need to be ingested into log aggregation systems like Splunk for analysis, alerting, and correlation.

The JSON logger provides structured logging optimized for ingestion into Splunk and other log management systems. It outputs single-line JSON with:

  • Splunk-friendly underscore field naming (e.g., event_host_name, event_service_name)
  • Complete event details including state, output, and summary
  • Operational metrics and execution details
  • Structured exception traces
  • Timezone-aware timestamps

Usage

Default (text logging):

$USER1$/eventhandler \
    --runner ssh \
    --decider default \
    --eventopt HOSTNAME='$HOSTNAME$' \
    --eventopt SERVICESTATE='$SERVICESTATE$'

JSON logging for Splunk ingestion:

$USER1$/eventhandler \
    --runner ssh \
    --decider default \
    --logger json \
    --eventopt HOSTNAME='$HOSTNAME$' \
    --eventopt SERVICESTATE='$SERVICESTATE$'

Custom logger:

$USER1$/eventhandler \
    --runner ssh \
    --logger mycustomlogger \
    --eventopt HOSTNAME='$HOSTNAME$'

Example Log Output

Text format (default):

2025-11-13 17:00:57,987 3468977 - INFO - executed action for dbserver02.example.com/MySQL: WARNING - Slow queries

JSON format:

{
  "timestamp": "2025-11-13T17:00:57.987487+01:00",
  "host_name": "oasch.example.com",
  "version": "2.9",
  "level": "INFO",
  "logger": "eventhandler_ssh",
  "omd_site": "demo_site",
  "event_host_name": "dbserver02.example.com",
  "event_service_name": "MySQL",
  "event_state": "WARNING",
  "event_notification_type": "PROBLEM",
  "event_service_output": "MySQL WARNING - Slow queries detected",
  "event_summary": "dbserver02.example.com/MySQL: WARNING - Slow queries",
  "msg": {
    "message": "executed action",
    "status": "success"
  }
}

Custom Loggers

You can create custom loggers by:

  1. Creating ~/local/lib/python/eventhandler/mylogger/logger.py
  2. Inheriting from EventhandlerLogger base class
  3. Implementing the log(level, message, context) method
from eventhandler.baseclass import EventhandlerLogger

class MyloggerLogger(EventhandlerLogger):
    def log(self, level, message, context=None):
        # Custom logging implementation
        pass

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

omdeventhandler-2.0.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

omdeventhandler-2.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file omdeventhandler-2.0.tar.gz.

File metadata

  • Download URL: omdeventhandler-2.0.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for omdeventhandler-2.0.tar.gz
Algorithm Hash digest
SHA256 a74592fe95c5ee14b6cf8a16ac5d25b3d8057b188527f21c358fc4759d6a33dd
MD5 6b810f6b952391a4ffb61d0b625ae121
BLAKE2b-256 95116e90d8f4a4e6043aaf3df94034391a61b0beda0baa48195ebee85161e44a

See more details on using hashes here.

File details

Details for the file omdeventhandler-2.0-py3-none-any.whl.

File metadata

  • Download URL: omdeventhandler-2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for omdeventhandler-2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1de8acfdad1b3db9d82793425b4b99de1d5eddaeb2132ac167fe580ec26dc8b5
MD5 d1f0c8c640e3f79f941f7d2f0ea60a4c
BLAKE2b-256 a953cc6598a88b4f68b69132a43681c24be20480836bd4e2fc67eda46fb26d68

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page