Refactor monitoring relay alert dispatch
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
|
||||
- Prometheus 抓取 `/metrics`
|
||||
- Alertmanager 根据规则聚合告警
|
||||
- Telegram relay 把告警推到运营频道
|
||||
- Relay 把告警推到运营频道
|
||||
- Grafana 展示趋势面板
|
||||
- 巡检脚本补健康检查
|
||||
|
||||
|
||||
@@ -59,6 +59,10 @@ def _send_telegram_message(text: str) -> None:
|
||||
continue
|
||||
|
||||
|
||||
def _send_alert_notifications(text: str) -> None:
|
||||
_send_telegram_message(text)
|
||||
|
||||
|
||||
class _Handler(BaseHTTPRequestHandler):
|
||||
def do_GET(self) -> None: # noqa: N802
|
||||
if self.path.rstrip("/") == "/healthz":
|
||||
@@ -83,7 +87,7 @@ class _Handler(BaseHTTPRequestHandler):
|
||||
if not isinstance(payload, dict):
|
||||
self.send_error(400, "invalid payload")
|
||||
return
|
||||
_send_telegram_message(_format_alerts(payload))
|
||||
_send_alert_notifications(_format_alerts(payload))
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "application/json; charset=utf-8")
|
||||
self.end_headers()
|
||||
|
||||
Reference in New Issue
Block a user