@Test public void testSlackAlertWithNoChannel() { _notifier = new MockSlackSelfHealingNotifier(MOCK_TIME); _notifier._slackWebhook = "http: _notifier.alert(FAILURES, false, 1L, KafkaAnomalyType.BROKER_FAILURE); assertEquals(0, _notifier.getSlackMessageList().size()); }
@Override public void alert(Object anomaly, boolean autoFixTriggered, long selfHealingStartTime, AnomalyType anomalyType) { super.alert(anomaly, autoFixTriggered, selfHealingStartTime, anomalyType); if (_slackWebhook == null) { LOG.warn("Slack webhook is null, can't send Slack self healing notification"); return; } if (_slackChannel == null) { LOG.warn("Slack channel name is null, can't send Slack self healing notification"); return; } String text = String.format("%s detected %s. Self healing %s.%s", anomalyType, anomaly, _selfHealingEnabled.get(anomalyType) ? String.format("start time %s", toDateString(selfHealingStartTime)) : "is disabled", autoFixTriggered ? "%nSelf-healing has been triggered." : ""); try { sendSlackMessage(new SlackMessage(_slackUser, text, _slackIcon, _slackChannel), _slackWebhook); } catch (IOException e) { LOG.warn("ERROR sending alert to Slack", e); } }
SlackSelfHealingNotifier extends SelfHealingNotifier { @Override public void alert(Object anomaly, boolean autoFixTriggered, long selfHealingStartTime, AnomalyType anomalyType) { super.alert(anomaly, autoFixTriggered, selfHealingStartTime, anomalyType); if (_slackWebhook == null) { LOG.warn("Slack webhook is null, can't send Slack self healing notification"); return; } if (_slackChannel == null) { LOG.warn("Slack channel name is null, can't send Slack self healing notification"); return; } String text = String.format("%s detected %s. Self healing %s.%s", anomalyType, anomaly, _selfHealingEnabled.get(anomalyType) ? String.format("start time %s", toDateString(selfHealingStartTime)) : "is disabled", autoFixTriggered ? "%nSelf-healing has been triggered." : ""); try { sendSlackMessage(new SlackMessage(_slackUser, text, _slackIcon, _slackChannel), _slackWebhook); } catch (IOException e) { LOG.warn("ERROR sending alert to Slack", e); } } }
SlackSelfHealingNotifier extends SelfHealingNotifier { @Override public void alert(Object anomaly, boolean autoFixTriggered, long selfHealingStartTime, AnomalyType anomalyType) { super.alert(anomaly, autoFixTriggered, selfHealingStartTime, anomalyType); if (_slackWebhook == null) { LOG.warn("Slack webhook is null, can't send Slack self healing notification"); return; } if (_slackChannel == null) { LOG.warn("Slack channel name is null, can't send Slack self healing notification"); return; } String text = String.format("%s detected %s. Self healing %s.%s", anomalyType, anomaly, _selfHealingEnabled.get(anomalyType) ? String.format("start time %s", toDateString(selfHealingStartTime)) : "is disabled", autoFixTriggered ? "%nSelf-healing has been triggered." : ""); try { sendSlackMessage(new SlackMessage(_slackUser, text, _slackIcon, _slackChannel), _slackWebhook); } catch (IOException e) { LOG.warn("ERROR sending alert to Slack", e); } } SlackSelfHealingNotifier();  SlackSelfHealingNotifier(Time time); }
SlackSelfHealingNotifier extends SelfHealingNotifier { @Override public void alert(Object anomaly, boolean autoFixTriggered, long selfHealingStartTime, AnomalyType anomalyType) { super.alert(anomaly, autoFixTriggered, selfHealingStartTime, anomalyType); if (_slackWebhook == null) { LOG.warn("Slack webhook is null, can't send Slack self healing notification"); return; } if (_slackChannel == null) { LOG.warn("Slack channel name is null, can't send Slack self healing notification"); return; } String text = String.format("%s detected %s. Self healing %s.%s", anomalyType, anomaly, _selfHealingEnabled.get(anomalyType) ? String.format("start time %s", toDateString(selfHealingStartTime)) : "is disabled", autoFixTriggered ? "%nSelf-healing has been triggered." : ""); try { sendSlackMessage(new SlackMessage(_slackUser, text, _slackIcon, _slackChannel), _slackWebhook); } catch (IOException e) { LOG.warn("ERROR sending alert to Slack", e); } } SlackSelfHealingNotifier();  SlackSelfHealingNotifier(Time time); @Override void configure(Map<String, ?> config); @Override void alert(Object anomaly, boolean autoFixTriggered, long selfHealingStartTime, AnomalyType anomalyType); }
SlackSelfHealingNotifier extends SelfHealingNotifier { @Override public void alert(Object anomaly, boolean autoFixTriggered, long selfHealingStartTime, AnomalyType anomalyType) { super.alert(anomaly, autoFixTriggered, selfHealingStartTime, anomalyType); if (_slackWebhook == null) { LOG.warn("Slack webhook is null, can't send Slack self healing notification"); return; } if (_slackChannel == null) { LOG.warn("Slack channel name is null, can't send Slack self healing notification"); return; } String text = String.format("%s detected %s. Self healing %s.%s", anomalyType, anomaly, _selfHealingEnabled.get(anomalyType) ? String.format("start time %s", toDateString(selfHealingStartTime)) : "is disabled", autoFixTriggered ? "%nSelf-healing has been triggered." : ""); try { sendSlackMessage(new SlackMessage(_slackUser, text, _slackIcon, _slackChannel), _slackWebhook); } catch (IOException e) { LOG.warn("ERROR sending alert to Slack", e); } } SlackSelfHealingNotifier();  SlackSelfHealingNotifier(Time time); @Override void configure(Map<String, ?> config); @Override void alert(Object anomaly, boolean autoFixTriggered, long selfHealingStartTime, AnomalyType anomalyType); static final String SLACK_SELF_HEALING_NOTIFIER_WEBHOOK; static final String SLACK_SELF_HEALING_NOTIFIER_ICON; static final String SLACK_SELF_HEALING_NOTIFIER_USER; static final String SLACK_SELF_HEALING_NOTIFIER_CHANNEL; static final String DEFAULT_SLACK_SELF_HEALING_NOTIFIER_ICON; static final String DEFAULT_SLACK_SELF_HEALING_NOTIFIER_USER; }