mirror of
https://github.com/marcredhat/SIEM-toolkit-patched
synced 2026-06-10 21:31:19 +00:00
Ingest Dashboard: optional background cache pre-warmer
Adds an asyncio background task that re-runs the heavy Ingest Dashboard
queries every ~4 min (just under the 5 min TTL) so the in-process cache
is always populated. First user hit on any dashboard widget then returns
from cache (single-digit ms) instead of waiting 30-60s for SDL.
Components:
- backend/services/prewarmer.py: standalone module, opt-in via
INGEST_PREWARM=1; configurable windows via INGEST_PREWARM_HOURS /
INGEST_PREWARM_DAYS / INGEST_PREWARM_DAILY_VOLUME_DAYS and interval
via INGEST_PREWARM_INTERVAL_SECONDS. Logs through the uvicorn logger
so cycles are visible in 'docker logs'.
- backend/main.py: spawn the task on FastAPI startup.
- docker-compose.yml: forward INGEST_PREWARM* env vars to the
backend service (default off).
Measured on Purple AI tenant (INGEMeasured on Purple AI tenant (INGEMeasured on Purple fMeasured on Purple AI tenant (INGEMeasured on Purple AI tenant (INGEMeasured on (INGEST_PREWARM=0) so non-opt-in
users see no behaviour change.
This commit is contained in:
@@ -45,6 +45,14 @@ with engine.connect() as _conn:
|
||||
app = FastAPI(title="SIEM Toolkit", version="1.0.0")
|
||||
|
||||
|
||||
@app.on_event("startup")
|
||||
async def start_ingest_prewarmer():
|
||||
"""Start optional background pre-warmer for the Ingest Dashboard cache.
|
||||
Opt-in via INGEST_PREWARM=1. See backend/services/prewarmer.py."""
|
||||
from services import prewarmer
|
||||
prewarmer.start_if_enabled()
|
||||
|
||||
|
||||
@app.on_event("startup")
|
||||
async def auto_load_detections():
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user