mirror of
https://github.com/moan0s/alertbot.git
synced 2024-09-30 01:45:35 +00:00
Compare commits
No commits in common. "ab9625ea61c9b0e364b0010d1c6eda860fcbdb56" and "742ca95d8403770793baec3165f850fa639cdd0e" have entirely different histories.
ab9625ea61
...
742ca95d84
15
alertbot.py
15
alertbot.py
@ -162,15 +162,14 @@ def prometheus_alert_to_markdown(alert_data: dict) -> str:
|
||||
:return: Alert as fomatted markdown
|
||||
"""
|
||||
messages = []
|
||||
known_labels = ['alertname', 'instance', 'job']
|
||||
for alert in alert_data["alerts"]:
|
||||
title = alert['annotations']['description'] if hasattr(alert['annotations'], 'description') else alert['annotations']['summary']
|
||||
message = f"""**{alert['status']}** {'💚' if alert['status'] == 'resolved' else '🔥'}: {title}"""
|
||||
for label_name in known_labels:
|
||||
try:
|
||||
message += "\n* **{0}**: {1}".format(label_name.capitalize(), alert["labels"][label_name])
|
||||
except:
|
||||
pass
|
||||
message = (
|
||||
f"""**{alert['status']}** {'💚' if alert['status'] == 'resolved' else '🔥'}: {alert['annotations']['description']}
|
||||
* **Alertname:** {alert["labels"]['alertname']}
|
||||
* **Instance:** {alert["labels"]['instance']}
|
||||
* **Job:** {alert["labels"]['job']}
|
||||
"""
|
||||
)
|
||||
messages.append(message)
|
||||
return messages
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user