Analytics¶

Analytics dashboard for monitoring detection trends, risk analysis, and camera performance metrics.
What You're Looking At¶
The Analytics page provides comprehensive insights into security detection patterns, risk trends, and camera performance. Powered by Grafana dashboards, this page helps you understand activity patterns, identify anomalies, and monitor system health.
Layout Overview¶
+----------------------------------------------------------+
| HEADER: BarChart Icon | "Analytics" | Action Buttons |
+----------------------------------------------------------+
| |
| +----------------------------------------------------+ |
| | | |
| | GRAFANA DASHBOARD EMBED | |
| | | |
| | +------------+ +------------+ +------------+ | |
| | | Detection | | Risk | | Camera | | |
| | | Trends | | Analysis | | Performance| | |
| | +------------+ +------------+ +------------+ | |
| | | |
| | +------------------------------------------+ | |
| | | | | |
| | | VISUALIZATION PANELS | | |
| | | | | |
| | +------------------------------------------+ | |
| | | |
| +----------------------------------------------------+ |
| |
+----------------------------------------------------------+
The page embeds the HSI Analytics dashboard from Grafana, which provides:
- Detection Trends - Daily detection counts visualized over time
- Risk Analysis - Risk score distribution and historical breakdown
- Camera Activity - Metrics and activity patterns per camera
- Activity Baselines - Learned patterns for anomaly detection
Key Components¶
Header Controls¶
| Button | Function |
|---|---|
| Grafana / Native Toggle | Switch between embedded Grafana dashboard and native React components |
| Open in Grafana | Opens the full Grafana dashboard in a new tab for advanced features (Grafana view only) |
| Refresh | Reloads the embedded dashboard (Grafana view only) |
View Modes¶
The Analytics page supports two view modes:
Grafana View (Default)¶
The primary view embeds the HSI Analytics Grafana dashboard (hsi-analytics) in kiosk mode. This provides:
- Consistent visualization style with other monitoring dashboards
- Auto-refresh every 30 seconds
- Full Grafana interactivity (zoom, pan, time range selection)
- Access to all Grafana features when opened in full mode
Native View¶
A fallback view showing select React-based analytics components:
| Component | Description |
|---|---|
| Camera Uptime Card | 7-day uptime statistics for all cameras |
| Pipeline Latency Panel | Real-time AI pipeline processing metrics |
Use native view when Grafana is unavailable or for quick access to specific metrics.
Grafana Dashboard Panels¶
The embedded Grafana dashboard includes panels for:
| Panel | Description |
|---|---|
| Detection Trend | Time series of daily detection counts |
| Risk Distribution | Breakdown of events by risk level (Low/Medium/High/Critical) |
| Camera Activity | Event counts and activity per camera |
| Object Distribution | Detection counts by object type |
| Risk History | Stacked area chart of risk levels over time |
Understanding Analytics Data¶
Detection Trends¶
The detection trend visualization shows how many detections occur over time:
| Pattern | Meaning |
|---|---|
| Activity spikes | Unusual increase in detections (potential event) |
| Quiet periods | Low activity (normal or potential camera issues) |
| Day/night cycles | Expected pattern for outdoor cameras |
| Consistent baseline | Normal operation |
Risk Analysis¶
Events are categorized by risk level based on AI analysis:
| Risk Level | Score Range | Color | Meaning |
|---|---|---|---|
| Low | 0-30 | Green | Routine activity |
| Medium | 31-60 | Yellow | Notable but expected |
| High | 61-80 | Orange | Requires attention |
| Critical | 81-100 | Red | Immediate review needed |
Camera Performance¶
Monitor camera health through:
- Uptime percentage - Days with detections vs. total days
- Activity distribution - Which cameras are most active
- Detection quality - Confidence scores of AI detections
Using Analytics Effectively¶
Daily Review¶
- Check detection trends for any unusual spikes
- Review high-risk events in the risk distribution panel
- Verify all cameras show expected activity
Weekly Review¶
- Compare this week's trends to previous weeks
- Look for pattern changes in activity levels
- Check if any cameras are underperforming
After Incidents¶
- Use time range selection to focus on incident period
- Review risk levels during the timeframe
- Check which cameras captured the activity
Settings & Configuration¶
Grafana URL¶
The Grafana URL is automatically configured from the backend. If the embedded dashboard fails to load:
- Verify Grafana is running
- Check the
grafana_urlconfig setting - Verify network connectivity between frontend and Grafana
Dashboard Configuration¶
The HSI Analytics dashboard is provisioned automatically:
Auto-Refresh¶
The embedded dashboard refreshes every 30 seconds automatically. Use the manual Refresh button for immediate updates.
Troubleshooting¶
Dashboard Shows "No Data"¶
- Check time range: Expand the time period in Grafana
- Verify cameras are active: Check camera status in the Dashboard
- Check AI pipeline: Verify the detection pipeline is running
- Verify datasources: Confirm Grafana can reach the backend API
"Failed to load configuration" Error¶
The frontend couldn't fetch the Grafana URL from the backend:
- Verify the backend is running
- Check network connectivity
- The dashboard will use
/grafanaas a fallback
Dashboard Loads But Shows Empty Panels¶
- Check that data exists in the database
- Verify the Grafana datasource is configured correctly
- Try opening in full Grafana to see any error messages
Native View Shows Errors¶
If the native view components fail to load:
- Check backend API connectivity
- Verify the
/api/analytics/*endpoints are responding - Check browser console for specific error messages
Technical Deep Dive¶
Architecture¶
flowchart LR
subgraph DataSources["Data Sources"]
DB[(PostgreSQL)]
B[Backend API]
end
subgraph Visualization["Visualization"]
G[Grafana]
F[Frontend]
end
DB --> B
B --> G
G -->|iframe embed| F
B -->|native API| F
style DataSources fill:#e0f2fe
style Visualization fill:#dcfce7 Related Code¶
Frontend:
- Analytics Page:
frontend/src/components/analytics/AnalyticsPage.tsx - Camera Uptime Card:
frontend/src/components/analytics/CameraUptimeCard.tsx - Pipeline Latency Panel:
frontend/src/components/analytics/PipelineLatencyPanel.tsx - Grafana URL Utility:
frontend/src/utils/grafanaUrl.ts
Backend:
- Analytics Routes:
backend/api/routes/analytics.py - System Routes:
backend/api/routes/system.py(pipeline latency)
Infrastructure:
- Grafana Dashboard:
monitoring/grafana/dashboards/analytics.json - Grafana Container:
docker-compose.prod.yml(grafana service)
API Endpoints¶
| Endpoint | Method | Description |
|---|---|---|
/api/analytics/detection-trends | GET | Daily detection counts |
/api/analytics/risk-history | GET | Daily risk level breakdown |
/api/analytics/camera-uptime | GET | Camera uptime percentages |
/api/analytics/object-distribution | GET | Detection counts by object type |
/api/system/pipeline-latency | GET | Pipeline stage latencies |
Data Flow¶
- Detection data is stored in PostgreSQL via the AI pipeline
- Backend API aggregates and serves analytics data
- Grafana queries the backend API for visualizations
- Frontend embeds the Grafana dashboard in an iframe
- Native view components query the API directly
Quick Reference¶
When to Use Analytics¶
| Scenario | What to Look For |
|---|---|
| Daily monitoring | Detection trends, high-risk events |
| Camera issues | Low activity, missing detections |
| Security review | Risk distribution, activity patterns |
| Performance check | Pipeline latency (native view) |
Common Actions¶
| I want to... | Do this... |
|---|---|
| See overall trends | Use Grafana view (default) |
| Check pipeline health | Switch to Native view |
| Get more dashboard controls | Click "Open in Grafana" |
| Force data refresh | Click "Refresh" button |
| Compare time periods | Use Grafana time range picker |