Files

23 lines
535 B
Python

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}"