ändrar sattus ollama

This commit is contained in:
larssand
2026-07-06 11:31:06 +02:00
parent b7f49214cb
commit 2f208c91ca
4 changed files with 15 additions and 3 deletions

View File

@@ -628,6 +628,7 @@ async function refresh() {
configuration.log_source === 'graylog_mcp' && mcp.status !== 'refreshing' && enabledStreams.length > 0 && displayedRawEvents === 0 ? `<span class="sev-high">No raw events fetched from enabled streams. Check poll window, Graylog query, stream permissions, and Diagnostics -> Stream Coverage.</span>` : '', configuration.log_source === 'graylog_mcp' && mcp.status !== 'refreshing' && enabledStreams.length > 0 && displayedRawEvents === 0 ? `<span class="sev-high">No raw events fetched from enabled streams. Check poll window, Graylog query, stream permissions, and Diagnostics -> Stream Coverage.</span>` : '',
enabledWithNoRawEvents.length && mcp.status !== 'refreshing' ? `<span class="sev-high">${esc(enabledWithNoRawEvents.length)} enabled stream(s) returned zero raw events in ${esc(zeroRawWindow)}.</span>` : '', enabledWithNoRawEvents.length && mcp.status !== 'refreshing' ? `<span class="sev-high">${esc(enabledWithNoRawEvents.length)} enabled stream(s) returned zero raw events in ${esc(zeroRawWindow)}.</span>` : '',
mcp.coverage_warning ? `<span class="sev-high">${esc(mcp.coverage_warning)}</span>` : '', mcp.coverage_warning ? `<span class="sev-high">${esc(mcp.coverage_warning)}</span>` : '',
advisor.status === 'heuristic_fallback' ? `Profile advisor: heuristic fallback (${esc(advisor.error || 'advisor unavailable')})` : '',
advisor.status === 'error' ? `<span class="sev-high">Profile advisor error: ${esc(advisor.error || 'unknown error')}</span>` : '' advisor.status === 'error' ? `<span class="sev-high">Profile advisor error: ${esc(advisor.error || 'unknown error')}</span>` : ''
].filter(Boolean).join('<br>'); ].filter(Boolean).join('<br>');
document.getElementById('health').innerHTML = [ document.getElementById('health').innerHTML = [

View File

@@ -432,7 +432,13 @@ def build_status(
profile_suggestions = apply_profile_advice(profile_suggestions, advice) profile_suggestions = apply_profile_advice(profile_suggestions, advice)
profile_advisor_status = {"enabled": True, "status": "ok" if advice else "empty", "profiles_returned": len(advice), "model": str(runtime_values.get("profile_advisor_model", "") or "qwen3:8b")} profile_advisor_status = {"enabled": True, "status": "ok" if advice else "empty", "profiles_returned": len(advice), "model": str(runtime_values.get("profile_advisor_model", "") or "qwen3:8b")}
except Exception as exc: except Exception as exc:
profile_advisor_status = {"enabled": True, "status": "error", "error": str(exc), "model": str(runtime_values.get("profile_advisor_model", "") or "qwen3:8b")} profile_advisor_status = {
"enabled": True,
"status": "heuristic_fallback",
"error": str(exc),
"model": str(runtime_values.get("profile_advisor_model", "") or "qwen3:8b"),
"candidates": len(advisor_candidates),
}
for suggestion in profile_suggestions: for suggestion in profile_suggestions:
suggestion.setdefault("profile_advisor", {"status": "heuristic", "error": str(exc)}) suggestion.setdefault("profile_advisor", {"status": "heuristic", "error": str(exc)})
intel_ips = sorted( intel_ips = sorted(

View File

@@ -66,6 +66,10 @@ class DashboardTests(unittest.TestCase):
self.assertIn("No enabled streams were saved", HTML) self.assertIn("No enabled streams were saved", HTML)
self.assertIn("streams with existing profiles are selected for recovery", HTML) self.assertIn("streams with existing profiles are selected for recovery", HTML)
def test_dashboard_shows_profile_advisor_fallback_as_notice(self):
self.assertIn("heuristic_fallback", HTML)
self.assertIn("Profile advisor: heuristic fallback", HTML)
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()

View File

@@ -196,7 +196,7 @@ class MonitorTests(unittest.TestCase):
self.assertEqual(status["llm_assessment"]["status"], "ok") self.assertEqual(status["llm_assessment"]["status"], "ok")
self.assertEqual(status["llm_assessment"]["text"], "looks noisy") self.assertEqual(status["llm_assessment"]["text"], "looks noisy")
def test_profile_advisor_status_records_error(self): def test_profile_advisor_status_records_heuristic_fallback(self):
with tempfile.TemporaryDirectory() as tmp: with tempfile.TemporaryDirectory() as tmp:
log_path = Path(tmp) / "events.log" log_path = Path(tmp) / "events.log"
log_path.write_text("fgai_stream_id=windows fgai_stream=Windows username=alice eventid=4625 action=failure\n", encoding="utf-8") log_path.write_text("fgai_stream_id=windows fgai_stream=Windows username=alice eventid=4625 action=failure\n", encoding="utf-8")
@@ -207,8 +207,9 @@ class MonitorTests(unittest.TestCase):
status = build_status(str(log_path), config_path=str(config_path), incident_path=str(Path(tmp) / "incidents.json")) status = build_status(str(log_path), config_path=str(config_path), incident_path=str(Path(tmp) / "incidents.json"))
advisor = status["capabilities"]["profile_advisor"] advisor = status["capabilities"]["profile_advisor"]
self.assertEqual(advisor["status"], "error") self.assertEqual(advisor["status"], "heuristic_fallback")
self.assertIn("timeout", advisor["error"]) self.assertIn("timeout", advisor["error"])
self.assertEqual(advisor["candidates"], 1)
self.assertEqual(status["profile_suggestions"][0]["profile_advisor"]["status"], "heuristic") self.assertEqual(status["profile_suggestions"][0]["profile_advisor"]["status"], "heuristic")
self.assertIn("timeout", status["profile_suggestions"][0]["profile_advisor"]["error"]) self.assertIn("timeout", status["profile_suggestions"][0]["profile_advisor"]["error"])