mirror of
https://github.com/moan0s/alertbot.git
synced 2024-10-01 06:25:35 -04:00
Merge remote-tracking branch 'james/main'
This commit is contained in:
commit
6fadb6d25e
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user