Fix alert occurrence query formatting
- not properly handled "=" signs
Change-Id: I891ab4cb4fde2d42b04579817c00937a14c66c0c
Related-PROD: PRODX-7212
diff --git a/sf_notifier/helpers.py b/sf_notifier/helpers.py
index 1c99a0a..b425de4 100644
--- a/sf_notifier/helpers.py
+++ b/sf_notifier/helpers.py
@@ -14,7 +14,6 @@
# under the License.
import os
-import urllib
RESOLVED_STATUSES = ('UP', 'OK', 'resolved')
@@ -46,14 +45,13 @@
# switch from Console to Graph tab to show trends
condition_url = alert['generatorURL'].replace('g0.tab=1', 'g0.tab=0')
- # list alert instances in the cluster
- # because of Python formatting - double braces were used
+ # list alert firing instances in the cluster
+ # via query: ALERTS{alertname="<alertname>",alertstate="firing"}
alert_query = ('g1.range_input=1h&'
- 'g1.expr=ALERTS{{alertname="{alertname}",'
- 'alertstate="firing"}}&'
- 'g1.tab=0')
- alert_query = alert_query.format(**alert['labels'])
- alert_query = urllib.quote(alert_query)
+ 'g1.expr=ALERTS%7Balertname%3D%22'
+ '{}'
+ '%22%2Calertstate%3D%22firing%22%7D&'
+ 'g1.tab=0').format(alert['labels']['alertname'])
return '{}&{}'.format(condition_url, alert_query)