Загрузить файлы в «alert-processor/app»
This commit is contained in:
@@ -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}"
|
||||
Reference in New Issue
Block a user