Refactor monitoring relay alert dispatch
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
- Prometheus 抓取 `/metrics`
|
- Prometheus 抓取 `/metrics`
|
||||||
- Alertmanager 根据规则聚合告警
|
- Alertmanager 根据规则聚合告警
|
||||||
- Telegram relay 把告警推到运营频道
|
- Relay 把告警推到运营频道
|
||||||
- Grafana 展示趋势面板
|
- Grafana 展示趋势面板
|
||||||
- 巡检脚本补健康检查
|
- 巡检脚本补健康检查
|
||||||
|
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|||||||
Reference in New Issue
Block a user