Fixed the MCP error handling for large pulls.
This commit is contained in:
@@ -89,7 +89,9 @@ def _stream_coverage(runtime_values: dict[str, object], stream_profiles: dict[st
|
||||
"events_fetched": int(status.get("events_fetched", 0) or 0),
|
||||
"latest_event_time": str(status.get("latest_event_time", "")),
|
||||
"truncated": bool(status.get("truncated")),
|
||||
"health": "not_enabled" if not enabled else "missing_profile" if not profile else "no_events" if int(status.get("events_fetched", 0) or 0) == 0 else "learning" if total_fields and ready_fields < total_fields else "ready" if total_fields else "profile_needs_fields",
|
||||
"partial": bool(status.get("partial")),
|
||||
"error": str(status.get("error", "")),
|
||||
"health": "not_enabled" if not enabled else "partial_fetch" if status.get("partial") else "missing_profile" if not profile else "no_events" if int(status.get("events_fetched", 0) or 0) == 0 else "learning" if total_fields and ready_fields < total_fields else "ready" if total_fields else "profile_needs_fields",
|
||||
})
|
||||
return rows
|
||||
|
||||
@@ -145,18 +147,22 @@ def build_status(
|
||||
events.extend(stream_events)
|
||||
stream_statuses.append({"stream_id": stream_id, "stream_name": stream_name, **stream_status})
|
||||
truncated_streams = [item for item in stream_statuses if item.get("truncated")]
|
||||
partial_streams = [item for item in stream_statuses if item.get("partial")]
|
||||
warnings = []
|
||||
if partial_streams:
|
||||
warnings.append(f"{len(partial_streams)} stream(s) returned a partial MCP fetch; Graylog likely timed out or rejected a large paged query.")
|
||||
if truncated_streams:
|
||||
warnings.append(f"{len(truncated_streams)} stream(s) hit max_events_per_stream; high EPS means the analysis window is only partially sampled.")
|
||||
mcp_status = {
|
||||
"status": "connected",
|
||||
"status": "partial" if partial_streams else "connected",
|
||||
"streams": stream_statuses,
|
||||
"events_fetched": len(events),
|
||||
"range_seconds": range_seconds,
|
||||
"max_events_per_stream": max_events_per_stream,
|
||||
"partial_streams": len(partial_streams),
|
||||
"truncated_streams": len(truncated_streams),
|
||||
"coverage_status": "truncated" if truncated_streams else "complete_window",
|
||||
"coverage_warning": (
|
||||
f"{len(truncated_streams)} stream(s) hit max_events_per_stream; high EPS means the analysis window is only partially sampled."
|
||||
if truncated_streams else ""
|
||||
),
|
||||
"coverage_status": "partial" if partial_streams else "truncated" if truncated_streams else "complete_window",
|
||||
"coverage_warning": " ".join(warnings),
|
||||
}
|
||||
except RuntimeError as exc:
|
||||
mcp_status = {"status": "error", "error": str(exc)}
|
||||
|
||||
Reference in New Issue
Block a user