Refactor monitoring relay alert dispatch

This commit is contained in:
2569718930@qq.com
2026-04-02 23:30:52 +08:00
parent 95c0c452f1
commit 90791b6070
2 changed files with 6 additions and 2 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
- Prometheus 抓取 `/metrics` - Prometheus 抓取 `/metrics`
- Alertmanager 根据规则聚合告警 - Alertmanager 根据规则聚合告警
- Telegram relay 把告警推到运营频道 - Relay 把告警推到运营频道
- Grafana 展示趋势面板 - Grafana 展示趋势面板
- 巡检脚本补健康检查 - 巡检脚本补健康检查
+5 -1
View File
@@ -59,6 +59,10 @@ def _send_telegram_message(text: str) -> None:
continue continue
def _send_alert_notifications(text: str) -> None:
_send_telegram_message(text)
class _Handler(BaseHTTPRequestHandler): class _Handler(BaseHTTPRequestHandler):
def do_GET(self) -> None: # noqa: N802 def do_GET(self) -> None: # noqa: N802
if self.path.rstrip("/") == "/healthz": if self.path.rstrip("/") == "/healthz":
@@ -83,7 +87,7 @@ class _Handler(BaseHTTPRequestHandler):
if not isinstance(payload, dict): if not isinstance(payload, dict):
self.send_error(400, "invalid payload") self.send_error(400, "invalid payload")
return return
_send_telegram_message(_format_alerts(payload)) _send_alert_notifications(_format_alerts(payload))
self.send_response(200) self.send_response(200)
self.send_header("Content-Type", "application/json; charset=utf-8") self.send_header("Content-Type", "application/json; charset=utf-8")
self.end_headers() self.end_headers()