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:

  1. Go to Controls → Thresholds (for KPIs)
  2. Click Create Rule
  3. Select the workflow(s) to apply the rule to
  4. Configure the metric, threshold, and alert settings
  5. 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

OptionDescription
nameHuman-readable name for the rule
workflow_idApply to specific workflow, or "*" for all
enabledEnable/disable the rule
severitywarning, critical
auto_create_incidentAutomatically create incident on breach
alert_channelsList of channels to notify

KPI-Specific Options

OptionDescription
metricMetric to track (latency, tokens, cost, custom)
thresholdNumeric threshold value
comparatorgt, lt, gte, lte, eq
windowTime window for aggregation (e.g., "5m", "1h")

Drift-Specific Options

OptionDescription
metricMetric to monitor for drift
baseline_windowHistorical window for baseline (e.g., "7d")
detection_windowRecent window to compare (e.g., "1h")
sensitivitylow, medium, high

Anomaly-Specific Options

OptionDescription
metricMetric to monitor for anomalies
methodzscore, iqr, isolation_forest
thresholdAnomaly score threshold
min_samplesMinimum 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