Views
No views yet
| Challenge | Rule-Based Limitation | RL Advantage |
|---|---|---|
| Dynamic Patterns | Static thresholds fail as alert patterns evolve | Learns from feedback, adapts to changing distributions |
| Context Awareness | Cannot capture alert correlations or temporal dependencies | Discovers hidden relationships through experience |
| Resource Optimization | Fixed allocation ignores varying system states | Optimizes action selection under real-time constraints |
| False Positive Handling | Uniform treatment leads to alert fatigue | Learns nuanced confidence signals and noise patterns |
| Cascading Failures | Reactive approach misses early warning signs | Proactive detection through predictive state modeling |
alerts: List of active alerts with:
id: Unique alert identifiervisible_severity: Noisy severity score (0.0-1.0)confidence: Detection confidence (0.0-1.0)alert_type: Category (CPU, MEMORY, DISK, NETWORK, APPLICATION, SECURITY)age: Time steps since alert generationsystem_load: Current system resource utilization (0.0-1.0)queue_length: Number of unprocessed alertstime_remaining: Steps left in episodetrue_severity: Actual criticality of each alertcorrelations: Alert dependency graphfuture_failures: Predicted cascading failure probabilities1+10 # Critical alert correctly investigated
2+5 # Cascading failure prevented through correlation detection
3+3 # False positive correctly ignored
4-2 # Unnecessary investigation (resource waste)
5-8 # Missed critical alert
6-10 # System failure due to ignored critical issuecorrect_actions / total_actions(weighted_resolved_alerts * resource_efficiency)(prevented_failures - system_instability_penalty) / max_possible1# Clone repository
2git clone https://github.com/scalar/adaptive-alert-triage.git
3cd adaptive-alert-triage
4
5# Create virtual environment
6python -m venv venv
7source venv/bin/activate # On Windows: venv\Scripts\activate
8
9# Install dependencies
10pip install -r requirements.txt
11
12# Install package in editable mode
13pip install -e .1# Build Docker image
2docker build -t adaptive-alert-triage:latest .
3
4# Run validation
5docker run --rm adaptive-alert-triage:latest
6
7# Run evaluation with OpenAI API key
8docker run --rm -e OPENAI_API_KEY=your_key adaptive-alert-triage:latest python evaluation/evaluate.py1from adaptive_alert_triage.env import AdaptiveAlertTriageEnv
2from adaptive_alert_triage.models import Action
3
4# Initialize environment with easy task
5env = AdaptiveAlertTriageEnv(task_id="easy")
6
7# Reset environment
8observation = env.reset()
9
10# Run episode
11done = False
12total_reward = 0
13
14while not done:
15 # Example: investigate first alert
16 action = Action(
17 alert_id=observation.alerts[0].id,
18 action_type="INVESTIGATE"
19 )
20
21 observation, reward, done, info = env.step(action)
22 total_reward += reward.value
23
24print(f"Episode reward: {total_reward}")
25print(f"Task score: {info['task_score']}")1# Rule-based baseline
2python agents/baseline.py --task easy
3
4# OpenAI inference baseline (requires OPENAI_API_KEY)
5export OPENAI_API_KEY=your_key_here
6python agents/inference.py --task medium1# Run all baselines on all tasks
2python evaluation/evaluate.py
3
4# Generate comparison plots
5python evaluation/plots.py1# Run all tests
2pytest tests/
3
4# Run with coverage
5pytest --cov=src/adaptive_alert_triage tests/
6
7# Run specific test file
8pytest tests/test_env.py -vExternal World (Datadog/Kafka) ──POST /ingest/alerts──> Docker (FastAPI Server)
│
│ Internal: AdaptiveAlertTriageEnv
│ (real + synthetic alerts)
↓
External RL Trainer (SB3) ──/env/reset───────────> │ <──/env/step(action)── Obs/Reward/Done
│
↓
RL beats baselines! (0.61 → 0.82+)1# 1. Build and run the persistent RL server
2docker compose up --build -d
3
4# 2. Verify server health
5curl http://localhost:8000/health
6
7# 3. Send real alerts (simulate Datadog webhook)
8bash scripts/demo_webhook.sh
9
10# 4. Train external RL agent
11pip install stable-baselines3
12python train_external.py
13
14# 5. View metrics
15curl http://localhost:8000/metrics| Endpoint | Method | Description |
|---|---|---|
/health | GET | Health check (env_ready, queue_size) |
/metrics | GET | RL score vs baseline comparison |
/ingest/alerts | POST | Webhook receiver for Datadog/Kafka |
/env/reset/{task_id} | POST | Initialize episode (easy/medium/hard) |
/env/step | POST | Take RL action, receive obs/reward/done |
/env/state | GET | Debug: current episode state |
/tasks | GET | List available tasks |
/ws/train | WS | Real-time streaming RL loop |
1import websockets
2import json
3
4async with websockets.connect("ws://localhost:8000/ws/train") as ws:
5 # Reset
6 await ws.send(json.dumps({"type": "reset", "task_id": "hard"}))
7 obs = await ws.recv()
8
9 # Step loop
10 while True:
11 await ws.send(json.dumps({
12 "type": "step",
13 "action": {"alert_id": "A1", "action_type": "INVESTIGATE"}
14 }))
15 result = await ws.recv()
16 if json.loads(result)["done"]:
17 breakadaptive_alert_triage_openenv/
├── README.md # This file
├── pyproject.toml # Project metadata and dependencies
├── openenv.yaml # OpenEnv specification
├── Dockerfile # Container build instructions
├── requirements.txt # Python dependencies
│
├── src/adaptive_alert_triage/ # Core environment implementation
│ ├── __init__.py
│ ├── env.py # Main Gym environment
│ ├── models.py # Pydantic Observation/Action/Reward models
│ └── utils.py # Helper functions
│
├── tasks/ # Task definitions and graders
│ ├── easy.py # Basic prioritization
│ ├── medium.py # Resource-constrained triage
│ └── hard.py # Cascading failure prevention
│
├── rewards/ # Reward shaping logic
│ └── reward.py
│
├── agents/ # Baseline and example agents
│ ├── baseline.py # Rule-based threshold agent
│ └── inference.py # OpenAI API baseline
│
├── tests/ # Unit and integration tests
│ ├── test_env.py
│ ├── test_tasks.py
│ └── test_rewards.py
│
├── evaluation/ # Performance analysis
│ ├── evaluate.py # Run benchmarks
│ └── plots.py # Generate comparison charts
│
└── docker/ # Docker utilities
└── entrypoint.sh # Container startup scriptreset(), step(), state())openenv.yaml metadatablack .)