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":
|
if data['status'] == "firing":
|
||||||
return "prometheus-alert"
|
return "prometheus-alert"
|
||||||
else:
|
else:
|
||||||
return "grafana-resolved"
|
return "prometheus-resolved"
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -78,6 +78,8 @@ def get_alert_messages(alert_data: dict, raw_mode=False) -> list:
|
|||||||
messages = grafana_alert_to_markdown(alert_data)
|
messages = grafana_alert_to_markdown(alert_data)
|
||||||
elif alert_type == "prometheus-alert":
|
elif alert_type == "prometheus-alert":
|
||||||
messages = prometheus_alert_to_markdown(alert_data)
|
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":
|
elif alert_type == "uptime-kuma-alert":
|
||||||
messages = uptime_kuma_alert_to_markdown(alert_data)
|
messages = uptime_kuma_alert_to_markdown(alert_data)
|
||||||
elif alert_type == "uptime-kuma-resolved":
|
elif alert_type == "uptime-kuma-resolved":
|
||||||
@ -162,12 +164,11 @@ def prometheus_alert_to_markdown(alert_data: dict) -> str:
|
|||||||
messages = []
|
messages = []
|
||||||
for alert in alert_data["alerts"]:
|
for alert in alert_data["alerts"]:
|
||||||
message = (
|
message = (
|
||||||
f"""**{alert['status']}**: {alert['annotations']['description']}
|
f"""**{alert['status']}** {'💚' if alert['status'] == 'resolved' else '🔥'}: {alert['annotations']['description']}
|
||||||
|
|
||||||
* **Alertname:** {alert["labels"]['alertname']}
|
* **Alertname:** {alert["labels"]['alertname']}
|
||||||
* **Instance:** {alert["labels"]['instance']}
|
* **Instance:** {alert["labels"]['instance']}
|
||||||
* **Job:** {alert["labels"]['job']}
|
* **Job:** {alert["labels"]['job']}
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
messages.append(message)
|
messages.append(message)
|
||||||
return messages
|
return messages
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
maubot: 0.1.0
|
maubot: 0.1.0
|
||||||
id: de.hyteck.alertbot
|
id: de.hyteck.alertbot
|
||||||
version: 1.1.1
|
version: 1.1.2
|
||||||
license: AGPL-3.0-or-later
|
license: AGPL-3.0-or-later
|
||||||
modules:
|
modules:
|
||||||
- alertbot
|
- alertbot
|
||||||
main_class: AlertBot
|
main_class: AlertBot
|
||||||
webapp: true
|
webapp: true
|
||||||
|
Loading…
Reference in New Issue
Block a user