Generate silence url for prom alertmanager alerts
This commit is contained in:
parent
63b351771a
commit
301c3220f5
2 changed files with 8 additions and 0 deletions
|
|
@ -29,7 +29,9 @@ def prometheus_alert_to_markdown(
|
|||
ignore_labels = ["grafana_folder"]
|
||||
|
||||
logging.debug(f"alertmanager payload: {alert_data}")
|
||||
externalURL = alert_data.get("externalURL")
|
||||
for alert in alert_data["alerts"]:
|
||||
alertname = alert["labels"]["alertname"]
|
||||
title = alert["labels"]["alertname"]
|
||||
summary = alert["annotations"].get("summary")
|
||||
description = alert["annotations"].get("description")
|
||||
|
|
@ -70,6 +72,10 @@ def prometheus_alert_to_markdown(
|
|||
dashboardURL = alert.get("dashboardURL")
|
||||
silenceURL = alert.get("silenceURL")
|
||||
actions = []
|
||||
if not silenceURL and externalURL:
|
||||
silence_filter = f"alertname%3D%22{alertname}%22"
|
||||
silence_filter = "{" + silence_filter + "}"
|
||||
silenceURL = f"{externalURL}/#/silences/new?filter={silence_filter}"
|
||||
if silenceURL:
|
||||
actions.append(f"[🔕 Mute]({silenceURL})")
|
||||
if runbookURL:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue