Implemented the next multi-source detection layer in this repository.
This commit is contained in:
@@ -41,11 +41,12 @@ def _records(value: object) -> Iterable[dict[str, object]]:
|
||||
|
||||
|
||||
class GraylogStreamSource:
|
||||
def __init__(self, client: GraylogMcpClient, stream: str, query: str = "*", field_mapping: str = "", stream_label: str = "") -> None:
|
||||
def __init__(self, client: GraylogMcpClient, stream: str, query: str = "*", field_mapping: str = "", stream_label: str = "", profile_fields: tuple[str, ...] = ()) -> None:
|
||||
self.client = client
|
||||
self.stream = stream
|
||||
self.query = query or "*"
|
||||
self.stream_label = stream_label or stream
|
||||
self.profile_fields = tuple(str(field).lower() for field in profile_fields if field)
|
||||
try:
|
||||
self.mapping = json.loads(field_mapping) if field_mapping else {}
|
||||
except json.JSONDecodeError as exc:
|
||||
@@ -59,7 +60,7 @@ class GraylogStreamSource:
|
||||
arguments: dict[str, object] = {
|
||||
"query": self.query,
|
||||
"range_seconds": 300,
|
||||
"fields": list(dict.fromkeys([*DEFAULT_FIELDS, *mapping_fields])),
|
||||
"fields": list(dict.fromkeys([*DEFAULT_FIELDS, *mapping_fields, *self.profile_fields])),
|
||||
}
|
||||
if self.stream:
|
||||
arguments["streams"] = [self.stream]
|
||||
|
||||
Reference in New Issue
Block a user