fix entriy view UI
This commit is contained in:
@@ -480,7 +480,7 @@ def write_status(status: dict[str, object], output: str) -> None:
|
||||
tmp_path.replace(output_path)
|
||||
|
||||
|
||||
def write_refreshing_status(output: str) -> None:
|
||||
def write_refreshing_status(output: str, *, cache_path: str | None = None) -> None:
|
||||
output_path = Path(output)
|
||||
try:
|
||||
current = json.loads(output_path.read_text(encoding="utf-8")) if output_path.exists() else {}
|
||||
@@ -488,6 +488,12 @@ def write_refreshing_status(output: str) -> None:
|
||||
current = {}
|
||||
if not isinstance(current, dict):
|
||||
current = {}
|
||||
used_cache = False
|
||||
if cache_path:
|
||||
cached = StatusSnapshotStore(cache_path).load("last_good")
|
||||
if cached:
|
||||
current = cached
|
||||
used_cache = True
|
||||
previous_mcp = current.get("capabilities", {}).get("graylog_mcp", {}) if isinstance(current.get("capabilities"), dict) else {}
|
||||
current.setdefault("status_schema", 2)
|
||||
current["generated_at"] = int(time.time())
|
||||
@@ -495,17 +501,27 @@ def write_refreshing_status(output: str) -> None:
|
||||
current["stale_reason"] = ""
|
||||
capabilities = current.setdefault("capabilities", {})
|
||||
if isinstance(capabilities, dict):
|
||||
previous_events = previous_mcp.get("events_fetched", 0) if isinstance(previous_mcp, dict) else 0
|
||||
previous_raw_events = previous_mcp.get("raw_events_fetched", 0) if isinstance(previous_mcp, dict) else 0
|
||||
previous_aggregate_events = previous_mcp.get("aggregate_events", 0) if isinstance(previous_mcp, dict) else 0
|
||||
previous_fetch_mode = previous_mcp.get("fetch_mode", "") if isinstance(previous_mcp, dict) else ""
|
||||
previous_coverage_status = previous_mcp.get("coverage_status", "") if isinstance(previous_mcp, dict) else ""
|
||||
capabilities["graylog_mcp"] = {
|
||||
"status": "refreshing",
|
||||
"previous_status": previous_mcp.get("status", "") if isinstance(previous_mcp, dict) else "",
|
||||
"previous_error": previous_mcp.get("error", "") if isinstance(previous_mcp, dict) else "",
|
||||
"previous_events_fetched": previous_mcp.get("events_fetched", 0) if isinstance(previous_mcp, dict) else 0,
|
||||
"previous_raw_events_fetched": previous_mcp.get("raw_events_fetched", 0) if isinstance(previous_mcp, dict) else 0,
|
||||
"previous_aggregate_events": previous_mcp.get("aggregate_events", 0) if isinstance(previous_mcp, dict) else 0,
|
||||
"previous_fetch_mode": previous_mcp.get("fetch_mode", "") if isinstance(previous_mcp, dict) else "",
|
||||
"previous_coverage_status": previous_mcp.get("coverage_status", "") if isinstance(previous_mcp, dict) else "",
|
||||
"previous_events_fetched": previous_events,
|
||||
"previous_raw_events_fetched": previous_raw_events,
|
||||
"previous_aggregate_events": previous_aggregate_events,
|
||||
"previous_fetch_mode": previous_fetch_mode,
|
||||
"previous_coverage_status": previous_coverage_status,
|
||||
"events_fetched": previous_events,
|
||||
"raw_events_fetched": previous_raw_events,
|
||||
"aggregate_events": previous_aggregate_events,
|
||||
"fetch_mode": previous_fetch_mode,
|
||||
"coverage_status": previous_coverage_status or "refreshing",
|
||||
}
|
||||
current["status_cache"] = {"served_from_cache": False, "reason": "refreshing"}
|
||||
current["status_cache"] = {"served_from_cache": used_cache, "reason": "refreshing"}
|
||||
write_status(current, output)
|
||||
|
||||
|
||||
@@ -534,7 +550,7 @@ def monitor_loop(
|
||||
effective_llm = bool(runtime.get("llm_enabled")) if runtime else llm
|
||||
effective_model = str(runtime.get("llm_model") or llm_model or "")
|
||||
if runtime.get("log_source") == "graylog_mcp":
|
||||
write_refreshing_status(output)
|
||||
write_refreshing_status(output, cache_path=status_cache_path)
|
||||
status = build_status(
|
||||
log_path, policy_path=policy_path, anomaly_limit=anomaly_limit,
|
||||
baseline_path=baseline_path, config_path=config_path, history_path=history_path,
|
||||
|
||||
Reference in New Issue
Block a user