Reads alarms from Kafka and then notifies the customer using their configured notification method.
Project description
Notification Engine
This engine reads alarms from Kafka and then notifies the customer using the configured notification method. Multiple notification and retry engines can run in parallel, up to one per available Kafka partition. Zookeeper is used to negotiate access to the Kafka partitions whenever a new process joins or leaves the working set.
Architecture
The notification engine generates notifications using the following steps:
Read Alarms from Kafka, with no auto commit. - monasca_common.kafka.KafkaConsumer class
Determine notification type for an alarm. Done by reading from mysql. - AlarmProcessor class
Send notification. - NotificationProcessor class
Add successful notifications to a sent notification topic. - NotificationEngine class
Add failed notifications to a retry topic. - NotificationEngine class
Commit offset to Kafka - KafkaConsumer class
The notification engine uses three Kafka topics:
alarm_topic: Alarms inbound to the notification engine.
notification_topic: Successfully sent notifications.
notification_retry_topic: Failed notifications.
A retry engine runs in parallel with the notification engine and gives any failed notification a configurable number of extra chances at success.
The retry engine generates notifications using the following steps:
Read notification json data from Kafka, with no auto commit. - KafkaConsumer class
Rebuild the notification that failed. - RetryEngine class
Send notification. - NotificationProcessor class
Add successful notifications to a sent notification topic. - RetryEngine class
Add failed notifications that have not hit the retry limit back to the retry topic. - RetryEngine class
Discard failed notifications that have hit the retry limit. - RetryEngine class
Commit offset to Kafka. - KafkaConsumer class
The retry engine uses two Kafka topics:
notification_retry_topic: Notifications that need to be retried.
notification_topic: Successfully sent notifications.
Fault Tolerance
When reading from the alarm topic, no committing is done. The committing is done only after processing. This allows the processing to continue even though some notifications can be slow. In the event of a catastrophic failure some notifications could be sent but the alarms have not yet been acknowledged. This is an acceptable failure mode, better to send a notification twice than not at all.
The general process when a major error is encountered is to exit the daemon which should allow the other processes to renegotiate access to the Kafka partitions. It is also assumed that the notification engine will be run by a process supervisor which will restart it in case of a failure. In this way, any errors which are not easy to recover from are automatically handled by the service restarting and the active daemon switching to another instance.
Though this should cover all errors, there is the risk that an alarm or a set of alarms can be processed and notifications are sent out multiple times. To minimize this risk a number of techniques are used:
Timeouts are implemented for all notification types.
An alarm TTL is utilized. Any alarm older than the TTL is not processed.
Operation
oslo.config is used for handling configuration options. A sample configuration file etc/monasca/notification.conf.sample can be generated by running:
tox -e genconfig
To run the service using the default config file location of /etc/monasca/notification.conf:
monasca-notification
To run the service and explicitly specify the config file:
monasca-notification --config-file /etc/monasca/monasca-notification.conf
Monitoring
StatsD is incorporated into the daemon and will send all stats to the StatsD server launched by monasca-agent. Default host and port points to localhost:8125.
Counters
ConsumedFromKafka
AlarmsFailedParse
AlarmsNoNotification
NotificationsCreated
NotificationsSentSMTP
NotificationsSentWebhook
NotificationsSentPagerduty
NotificationsSentFailed
NotificationsInvalidType
AlarmsFinished
PublishedToKafka
Timers
ConfigDBTime
SendNotificationTime
Future Considerations
More extensive load testing is needed:
How fast is the mysql db? How much load do we put on it. Initially I think it makes most sense to read notification details for each alarm but eventually I may want to cache that info.
How expensive are commits to Kafka for every message we read? Should we commit every N messages?
How efficient is the default Kafka consumer batch size?
Currently we can get ~200 notifications per second per NotificationEngine instance using webhooks to a local http server. Is that fast enough?
Are we putting too much load on Kafka at ~200 commits per second?
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for monasca-notification-1.17.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25f40d45271e3c4f3296968fb36130ccb568a1df780cf01fa3c20cf0661cf841 |
|
MD5 | d789cd030b2ec18d4c260e93a2d7f2ac |
|
BLAKE2b-256 | ae7335046d548d30e0c48494f59edc2189116a41f28e22562623d340e3c30ef1 |
Hashes for monasca_notification-1.17.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a28a8e4ac45fc33fe512d4f4a68a003a877cd7c330d61c9fdb7193b087dee88 |
|
MD5 | c96a78e35095cf459a5ae3fe46a8f9a0 |
|
BLAKE2b-256 | 05c8afe574c3e9ca8672889473d55c5073a1f734c2867aeb517d4121b912d7a3 |