Switch to /api/v1/alerts/groups so we can filter out silenced alerts
@@ -646,10 +646,13 @@ class Mute(FormView):
class AjaxAlert(View):
def get(self, request):
alerts = collections.defaultdict(list)
- url = urljoin(settings.PROMGEN['alertmanager']['url'], '/api/v1/alerts')
- print(url)
+ url = urljoin(settings.PROMGEN['alertmanager']['url'], '/api/v1/alerts/groups')
response = requests.get(url)
- for alert in response.json().get('data', []):
+ for group in response.json().get('data', []):
+ for block in group.get('blocks', []):
+ for alert in block.get('alerts', []):
+ if alert.get('inhibited', False):
+ continue
alerts['alert-all'].append(alert)
for key in ['project', 'service']:
if key in alert['labels']:
@@ -657,5 +660,4 @@ class AjaxAlert(View):
alerts = {key: render_to_string('promgen/ajax_alert.html', {'alerts': alerts[key]}) for key in alerts}
-
return JsonResponse(alerts)
