Controls Overview
Define custom rules to monitor KPIs, detect drift, identify anomalies, and configure alert channels.
What are Controls?
Controls are configurable rules that monitor your AI agents and trigger alerts when thresholds are breached. TuringPulse provides four types of controls:
Creating Rules via UI
Navigate to Controls in the sidebar to create and manage rules:
- Go to Controls → Thresholds (for KPIs)
- Click Create Rule
- Select the workflow(s) to apply the rule to
- Configure the metric, threshold, and alert settings
- Save and enable the rule
Creating Rules via SDK
You can also define rules directly in your code:
agent_with_kpis.py
from turingpulse import instrument, KPIConfig
@instrument(
agent_id="my-agent",
kpis=[
# Latency threshold
KPIConfig(
kpi_id="latency_ms",
use_duration=True,
alert_threshold=5000,
comparator="gt",
auto_create_incident=True,
),
# Cost threshold
KPIConfig(
kpi_id="cost_usd",
value=lambda ctx: ctx.metadata.get("cost", 0),
alert_threshold=1.0,
comparator="gt",
),
]
)
def my_agent(query: str):
return process(query)Rule Configuration Options
Common Options
| Option | Description |
|---|---|
name | Human-readable name for the rule |
workflow_id | Apply to specific workflow, or "*" for all |
enabled | Enable/disable the rule |
severity | warning, critical |
auto_create_incident | Automatically create incident on breach |
alert_channels | List of channels to notify |
KPI-Specific Options
| Option | Description |
|---|---|
metric | Metric to track (latency, tokens, cost, custom) |
threshold | Numeric threshold value |
comparator | gt, lt, gte, lte, eq |
window | Time window for aggregation (e.g., "5m", "1h") |
Drift-Specific Options
| Option | Description |
|---|---|
metric | Metric to monitor for drift |
baseline_window | Historical window for baseline (e.g., "7d") |
detection_window | Recent window to compare (e.g., "1h") |
sensitivity | low, medium, high |
Anomaly-Specific Options
| Option | Description |
|---|---|
metric | Metric to monitor for anomalies |
method | zscore, iqr, isolation_forest |
threshold | Anomaly score threshold |
min_samples | Minimum samples before detection |
Alert Channels
Configure where alerts are sent when rules are triggered:
- Email - Send to individual or group emails
- Slack - Post to Slack channels via webhook
- PagerDuty - Create incidents in PagerDuty
- Webhook - Send to any HTTP endpoint
💡
Best Practice
Create separate alert channels for different severity levels. Route critical alerts to PagerDuty and warnings to Slack.
Next Steps
- KPI Rules - Detailed KPI configuration
- Drift Detection - Set up drift monitoring
- Anomaly Rules - Configure anomaly detection
- Alert Channels - Set up notifications