This project implements an event monitoring and alerting system. It simulates the generation of different types of events and monitors them using predefined alert configurations. When a threshold is breached, the system dispatches alerts via different strategies such as console output or email.
- Python 3.10+
-
alerting_system/
monitoring.py
: Contains theMonitoringService
class that monitors events and triggers alerts.dispatcher.py
: Contains classes for dispatching alerts via different strategies (singleton).logger.py
: Custom logger that supports formatting and color based on log levels (singleton).
-
models/
event.py
: Contains theEvent
class representing an event.
-
config/
config.py
: Contains the configuration for alerts.
-
literals/
counts.py
: Defines constants for the number of different types of events.enums.py
: Defines enums for alert types, event types, and dispatch types.messages.py
: Defines messages for logs.
-
constants/
alert_configs.py
: Contains the alert configurations.
-
main.py
: Main file. -
output.png
: Sample console screenshot.
- Clone the repository.
- Run the
main.py
script.
python main.py
The main
function simulates the generation of events and processes them using the MonitoringService
.
- Initialize Monitoring Service (Singleton): The
MonitoringService
is initialized with predefined alert configurations. - Generate Events: Different types of events are generated for different clients:
PAYMENT_EXCEPTION
events for client X.USERSERVICE_EXCEPTION
events for client X.LOGIN_FAILURE
events for client Y.
- Process Events: Each event is processed by the
MonitoringService
to check if any alert thresholds are breached.
To add new event types:
- Define the event type in
literals/enums.py
. - Update the event generation logic in the
main
function. - Add corresponding alert configurations in
constants/alert_configs.py
.
To add new alert dispatch strategies:
- Define the new dispatch type in
literals/enums.py
. - Implement the dispatch logic in
alerting_system/dispatcher.py
. - Update alert configurations to use the new dispatch strategy.
This project is licensed under the MIT License.
This README provides an overview of the project, its structure, how to run it, and guidelines for extending the functionality.