use of org.graylog2.alarmcallbacks.AlarmCallbackHistory in project graylog2-server by Graylog2.
the class AlertNotificationsSender method send.
public void send(AlertCondition.CheckResult result, Stream stream, Alert alert, AlertCondition alertCondition) {
final List<AlarmCallbackConfiguration> callConfigurations = alarmCallbackConfigurationService.getForStream(stream);
// Checking if alarm callbacks have been defined
for (AlarmCallbackConfiguration configuration : callConfigurations) {
AlarmCallbackHistory alarmCallbackHistory;
AlarmCallback alarmCallback = null;
try {
alarmCallback = alarmCallbackFactory.create(configuration);
alarmCallback.call(stream, result);
alarmCallbackHistory = alarmCallbackHistoryService.success(configuration, alert, alertCondition);
} catch (Exception e) {
if (alarmCallback != null) {
LOG.warn("Alarm callback <" + alarmCallback.getName() + "> failed. Skipping.", e);
} else {
LOG.warn("Alarm callback with id " + configuration.getId() + " failed. Skipping.", e);
}
alarmCallbackHistory = alarmCallbackHistoryService.error(configuration, alert, alertCondition, e.getMessage());
}
try {
alarmCallbackHistoryService.save(alarmCallbackHistory);
} catch (Exception e) {
LOG.warn("Unable to save history of alarm callback run: ", e);
}
}
}
Aggregations