add more matching

This commit is contained in:
larssand
2026-06-22 19:19:31 +02:00
parent a5489d3c87
commit f2257c74de
8 changed files with 85 additions and 5 deletions

View File

@@ -41,10 +41,11 @@ def _records(value: object) -> Iterable[dict[str, object]]:
class GraylogStreamSource:
def __init__(self, client: GraylogMcpClient, stream: str, query: str = "*", field_mapping: str = "") -> None:
def __init__(self, client: GraylogMcpClient, stream: str, query: str = "*", field_mapping: str = "", stream_label: str = "") -> None:
self.client = client
self.stream = stream
self.query = query or "*"
self.stream_label = stream_label or stream
try:
self.mapping = json.loads(field_mapping) if field_mapping else {}
except json.JSONDecodeError as exc:
@@ -88,6 +89,7 @@ class GraylogStreamSource:
def _event(self, record: dict[str, object]) -> LogEvent:
fields = {str(key).lower(): str(value) for key, value in record.items() if value is not None}
fields["fgai_stream"] = self.stream_label
for canonical, candidates in DEFAULT_FIELD_MAP.items():
mapped = self.mapping.get(canonical)
candidates = (str(mapped),) if mapped else candidates