Merge remote-tracking branch 'james/main'

This commit is contained in:
Julian-Samuel Gebühr 2022-12-19 15:29:46 +01:00
commit 6fadb6d25e
2 changed files with 7 additions and 6 deletions

View File

@ -50,7 +50,7 @@ def get_alert_type(data):
if data['status'] == "firing":
return "prometheus-alert"
else:
return "grafana-resolved"
return "prometheus-resolved"
except KeyError:
pass
@ -78,6 +78,8 @@ def get_alert_messages(alert_data: dict, raw_mode=False) -> list:
messages = grafana_alert_to_markdown(alert_data)
elif alert_type == "prometheus-alert":
messages = prometheus_alert_to_markdown(alert_data)
elif alert_type == "prometheus-resolved":
messages = prometheus_alert_to_markdown(alert_data)
elif alert_type == "uptime-kuma-alert":
messages = uptime_kuma_alert_to_markdown(alert_data)
elif alert_type == "uptime-kuma-resolved":
@ -162,12 +164,11 @@ def prometheus_alert_to_markdown(alert_data: dict) -> str:
messages = []
for alert in alert_data["alerts"]:
message = (
f"""**{alert['status']}**: {alert['annotations']['description']}
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

View File

@ -1,8 +1,8 @@
maubot: 0.1.0
id: de.hyteck.alertbot
version: 1.1.1
version: 1.1.2
license: AGPL-3.0-or-later
modules:
- alertbot
main_class: AlertBot
webapp: true
webapp: true