Add update for IsWatchDogAlert__c
- plus add informational severity
- let watchdog bypass feed_item flag
Change-Id: I4946184b925f9783fcfe393b71c5ce4fe38bf8d2
Related-PROD: PRODX-18044
diff --git a/sf_notifier/salesforce/client.py b/sf_notifier/salesforce/client.py
index cf2f4c6..f86c2f0 100644
--- a/sf_notifier/salesforce/client.py
+++ b/sf_notifier/salesforce/client.py
@@ -1,7 +1,6 @@
import fcntl
import hashlib
import logging
-import os
import time
import uuid
from contextlib import contextmanager
@@ -20,6 +19,7 @@
STATE_MAP = {
'OK': '060 Informational',
'UP': '060 Informational',
+ 'INFORMATIONAL': '060 Informational',
'UNKNOWN': '070 Unknown',
'WARNING': '080 Warning',
'MINOR': '080 Warning',
@@ -210,6 +210,10 @@
alert_id_data += labels[key].replace(".", "\\.")
return self.hash_func(alert_id_data.encode('utf-8')).hexdigest()
+ @staticmethod
+ def _is_watchdog(labels):
+ return labels['alertname'].lower() == 'watchdog'
+
@sf_auth_retry
def _create_case(self, subject, body, labels, alert_id):
@@ -233,6 +237,9 @@
if labels.get('cluster_id') is not None:
payload['ClusterId__c'] = labels['cluster_id']
+ if self._is_watchdog(labels):
+ payload['IsWatchDogAlert__c'] = 'true'
+
logger.info('Try to create case: {}.'.format(payload))
try:
self.metrics['sf_request_count'].inc()
@@ -299,7 +306,7 @@
else:
response['status'] = 'created'
- if self.feed_enabled:
+ if self.feed_enabled or self._is_watchdog(labels):
self._create_feed_item(subject, body, case_id)
return response