-
Notifications
You must be signed in to change notification settings - Fork 3
AI Threat Analyst
Hybrid R-Sentry integrates an AI threat analyst that automatically classifies every HIGH, CRITICAL, and MEDIUM detection event using a large language model.
The AI analyst supports three providers with automatic fallback:
1. Cerebras (AI_API_KEY_CEREBRAS) — fastest (~200ms), optional
│ fails or not configured
▼
2. NVIDIA / Groq (NVIDIA_API_KEY) — primary fallback
│ fails
▼
3. NVIDIA / Groq (NVIDIA_API_KEY_ALERTS) — secondary fallback
Groq keys are auto-detected by the gsk_ prefix. NVIDIA keys start with nvapi-. Cerebras is skipped silently if AI_API_KEY_CEREBRAS is not set — the system works without it.
- Agent sends a detection event to the backend
- Backend dispatches
analyze_event_aiCelery task - Task immediately publishes a PENDING state to the
rsentry:aiRedis channel — the dashboard shows a spinner right away - Task calls the AI provider with structured event context
- LLM returns a JSON classification
- Result is published to the
rsentry:aiRedis channel asai_analysis_update - Dashboard receives the update via WebSocket and replaces the spinner with the result
- Result is cached in Redis for 24 hours for forensic export
The system uses two separate keys to prevent rate limiting from blocking both analysis types simultaneously:
| Key | Used For |
|---|---|
NVIDIA_API_KEY |
Live event analysis (AI Analyst page) |
NVIDIA_API_KEY_ALERTS |
On-demand alert analysis (Alerts page) |
Each key has its own Redis rate limit slot. They never block each other.
Every analysis returns structured JSON with these fields:
| Field | Description | Example |
|---|---|---|
threat_type |
Type of threat detected |
Ransomware, Cryptominer, Benign
|
technique |
Attack technique used |
File Encryption, Canary File Access
|
language_or_tool |
Tool or language involved |
Python, Bash, C binary
|
behavior_summary |
Plain English explanation | Process rapidly modified 40 files... |
risk_level |
Severity assessment |
CRITICAL, HIGH, MEDIUM, LOW
|
recommendation |
What the analyst should do | Isolate host immediately |
confidence |
Confidence in assessment |
HIGH, MEDIUM, LOW
|
When the AI classifies a threat as Benign or LOW risk, the linked alert is automatically acknowledged — no manual action needed. This reduces alert fatigue for common false positives.
The AI Analyst page includes a Run System Health Check button that:
- Fetches the last 100 events from the backend
- Sends them to the LLM for aggregate analysis
- Returns an overall system status assessment
Health check output includes:
| Field | Values |
|---|---|
status |
STABLE, UNDER_ATTACK, ANOMALOUS, RECOVERING
|
behavior_summary |
2-3 sentence description of overall activity |
risk_level |
Overall risk level |
recommendation |
What to do next |
The system uses a Lua-based atomic rate limiter in Redis to enforce a minimum delay between API calls per provider. This prevents hitting the rate limit while allowing multiple Celery workers to run in parallel.
AI analyses persist for 4 minutes after navigating away from the AI Analyst page. This is managed by lifting state to App.jsx with a 15-second expiry check interval.
If all providers fail (rate limit, network error, invalid key):
- An error card is displayed on the AI Analyst page
- The pending spinner is replaced with a visible error message
- The alert is not auto-acknowledged
- Celery logs the failure with the provider name and error reason