add more stats and fix

This commit is contained in:
larssand
2026-06-30 12:23:23 +02:00
parent 4af316c739
commit e144cd8258
4 changed files with 29 additions and 5 deletions

View File

@@ -81,7 +81,7 @@ class GraylogAggregateSource:
}
schema_variants: list[dict[str, object]] = []
metric_keys = [key for key in ("metrics", "series") if key in properties]
group_keys = [key for key in ("group_by", "groups", "fields") if key in properties]
group_keys = [key for key in ("groupings", "group_by", "groups", "fields") if key in properties]
if properties and metric_keys:
for metric_key in metric_keys:
for metric_value in (["count()"], ["count"], [{"function": "count"}]):
@@ -92,6 +92,27 @@ class GraylogAggregateSource:
if properties:
schema_variants.append(_filter_supported(base, properties))
fallback_variants: list[dict[str, object]] = [
{
"query": self.query,
"streams": [self.stream] if self.stream else [],
"range_seconds": max(1, int(range_seconds)),
"groupings": [],
"metrics": ["count()"],
},
{
"query": self.query,
"streams": [self.stream] if self.stream else [],
"range_seconds": max(1, int(range_seconds)),
"groupings": [],
"metrics": ["count"],
},
{
"query": self.query,
"streams": [self.stream] if self.stream else [],
"range_seconds": max(1, int(range_seconds)),
"groupings": [],
"metrics": [{"function": "count"}],
},
{
"query": self.query,
"streams": [self.stream] if self.stream else [],

View File

@@ -156,7 +156,7 @@ def build_status(
if use_aggregate:
aggregate_status = GraylogAggregateSource(GraylogMcpClient(url, token), stream_id, str(runtime_values.get("graylog_query", "*"))).fetch_count(range_seconds=range_seconds)
aggregate_events_total += int(aggregate_status.get("aggregate_events", 0) or 0)
raw_limit = raw_sample_events if use_aggregate else max_events_per_stream
raw_limit = min(raw_sample_events, 10_000) if use_aggregate else max_events_per_stream
stream_events, stream_status = GraylogStreamSource(GraylogMcpClient(url, token), stream_id, str(runtime_values.get("graylog_query", "*")), str(runtime_values.get("graylog_field_mapping", "")), stream_name, profile_fields).fetch(max_events=raw_limit, range_seconds=range_seconds)
events.extend(stream_events)
stream_statuses.append({"stream_id": stream_id, "stream_name": stream_name, **aggregate_status, **stream_status, "raw_sample_limit": raw_limit})