KPIs & Dashboards¶
The dashboard is the operational heart of LogSys: a live view of system health driven by KPI aggregates served from the KPIs API and pushed over WebSocket.
KPI Data Path¶
flowchart LR
PG[(PostgreSQL<br/>materialized views)] --> KV[KPI service]
KV --> CACHE[(Redis cache<br/>kpis_global:*)]
KV --> API[GET /api/kpis]
CACHE --> API
API --> REST[REST poll]
API --> WS[WS /ws/kpis]
REST --> UI[React dashboard]
WS --> UI
compute_kpisreads materialized views + live counts- Results cached in Redis (
kpis_global:*), invalidated on new events/clear-all - WebSocket sends
kpi:snapshoton connect and when the cache changes
KPI Cards¶
| Card | Source | Refresh |
|---|---|---|
| Total events | mv_dashboard_aggregates |
snapshot |
| Total occurrences | sum(occurrence_count) |
snapshot |
Error events (is_error_or_worse) |
matview filter | snapshot |
| Events last minute | events_last_min |
snapshot |
| Criticals 24h | criticals_24h |
snapshot |
| Priority counts (P1–P4) | events + template_priority |
snapshot |
| DLQ count | dlq_events |
snapshot |
Charts¶
| Chart | Data |
|---|---|
| Severity breakdown | GET /api/analytics/severity-breakdown |
| Top sources | GET /api/analytics/top-sources |
| Time series | GET /api/logs/meta/timeseries?window=… |
| Calendar | GET /api/logs/meta/calendar |
| DLQ vs stored | GET /api/analytics/dlq-vs-stored |
Real-time Behavior¶
- On mount,
useKpiStreamconnects to/ws/kpis - Server sends initial
kpi:snapshot— dashboard renders instantly - When new events are written, the pipeline publishes
events:newon Redis; KPI cache invalidates; next snapshot reflects it - Connection loss → auto-reconnect with backoff; interim REST polls keep data fresh
View Selectors¶
DashboardViewSelector lets operators switch between:
- Live view — real-time, WebSocket driven
- Range view — historical aggregates (REST)
Empty-State Handling¶
If no events exist (e.g. simulator stopped), charts show empty states and the time series endpoint returns an empty buckets array with has_more: false — no 500s, no spinner loops.
Related¶
- KPIs API — payload shape
- Real-time Updates — WebSocket consumption
- WebSocket API — protocol details