From a9799587afd8169d0117a1d0db8ee9e450774c12 Mon Sep 17 00:00:00 2001 From: Aleksandr Demshin Date: Tue, 19 Oct 2021 00:36:32 +0300 Subject: [PATCH] feat: Add logic to telegram plugin to check previous severity (#360) * fix syntax errors * add routing plugin * change alert duplicate count in routing plugin to 1 * fix routing * reinit plugin * update routing pluging * disable telegram notification for custom severity * remove routing plugin * disable telegram notification for custom severity * Revert "remove routing plugin" This reverts commit 0deefe05bc47be44dc0615ec81a392d43acfd00f. * Revert "update routing pluging" This reverts commit 7d5fc43dd753105d1212ef23e40a7dd75a535789. * Revert "add routing plugin" This reverts commit b14f434a88f81dca85cf51a6a225fb8e6f78f83e. * Revert "fix syntax errors" This reverts commit cc0d62c68a3f2fba11756bf12abfaca8242dc122. * disable TELEGRAM_DISABLE_NOTIFICATION_SEVERITY * revert * add checking previous severity for telegram forwarding * remove closed frome severity * remove 'closed' from severities --- plugins/telegram/alerta_telegram.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/telegram/alerta_telegram.py b/plugins/telegram/alerta_telegram.py index c708a7b9..de815069 100644 --- a/plugins/telegram/alerta_telegram.py +++ b/plugins/telegram/alerta_telegram.py @@ -116,6 +116,10 @@ def post_receive(self, alert): if alert.severity in TELEGRAM_DISABLE_NOTIFICATION_SEVERITY: return + if alert.severity in ['ok', 'normal', 'cleared', app.config.get('DEFAULT_NORMAL_SEVERITY')] and alert.previous_severity in TELEGRAM_DISABLE_NOTIFICATION_SEVERITY: + LOG.debug("Alert severity is %s but previous_severity was %s (included in DEFAULT_NORMAL_SEVERITY list), thus it will not be forwarded to Telegram." % (alert.severity, alert.previous_severity)) + return + LOG.debug('Telegram: post_receive sendMessage disable_notification=%s', str(disable_notification)) chat_ids = TELEGRAM_CHAT_ID.split(",")