Загрузить файлы в «alert-processor/app»

This commit is contained in:
2026-08-06 18:33:44 +03:00
parent 24ac6af45c
commit 8ff9e30993
5 changed files with 1140 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
from __future__ import annotations
import re
from app.models import NormalizedEvent
def _norm(value: str | None) -> str:
if not value:
return "unknown"
value = value.strip().lower()
value = re.sub(r"\s+", "_", value)
value = re.sub(r"[^a-z0-9_\-\.]+", "_", value)
return value.strip("_") or "unknown"
def build_fingerprint(event: NormalizedEvent) -> str:
host = _norm(event.host)
service = _norm(event.service)
trigger = _norm(event.trigger_name)
return f"{host}|{service}|{trigger}"