Eagle Notification Plugin provides an interface for users to consume Eagle alerts. When define a policy, a user can add an arbitrary number of notification plugin instances. By default, Eagle supports three types of notification: EagleStore, Kafka and Email
To integrate a customized notification plugin, we must implement an interface
public interface NotificationPlugin { /** * for initialization * @throws Exception */ void init(Config config, List<AlertDefinitionAPIEntity> initAlertDefs) throws Exception; /** * Update Plugin if any change in Policy Definition * @param policy to be impacted * @param notificationConfCollection * @throws Exception */ void update(String policy, List<Map<String,String>> notificationConfCollection , boolean isPolicyDelete) throws Exception; /** * Post a notification for the given alertEntity * @param alertEntity * @throws Exception */ void onAlert(AlertAPIEntity alertEntity) throws Exception; /** * Returns Status of Notification Post * @return */ List<NotificationStatus> getStatusList(); }
Examples: AlertKafkaPlugin, AlertEmailPlugin, and AlertEagleStorePlugin.
The second and crucial step is to register the configurations of the customized plugin. In other words, we need persist the configuration template into database in order to expose the configurations to users in the front end.
Examples:
{ "prefix": "alertNotifications", "tags": { "notificationType": "kafka" }, "className": "org.apache.eagle.notification.plugin.AlertKafkaPlugin", "description": "send alert to kafka bus", "enabled":true, "fields": "[{\"name\":\"kafka_broker\",\"value\":\"sandbox.hortonworks.com:6667\"},{\"name\":\"topic\"}]" }
‘fields’ is the configuration for notification type ‘kafka’
How can we do that? Here are Eagle other notification plugin configurations. Just append yours to it, and run this script when Eagle service is up.