Monitoring
Monitoring covers alert rules, rate limits, and behavioral metrics for your agents, including drift and anomaly detectors, and is available on all plans including Free. Each alert reads off the signed record Asqav writes for the action, so when a rule trips you can still verify what actually happened well after the fact.
Alert Rules
Create rules that trigger alerts when agent metrics exceed thresholds:
python
import asqav
asqav.init(api_key="sk_...")
# Create an alert rule
rule = Asqav.Monitoring.create_rule(
name="High error rate",
metric="error_rate",
condition="gt",
threshold=5.0,
window="5min"
)
print(f"Rule ID: {rule.id}")
print(f"Status: {rule.status}")
# Create a latency alert
latency_rule = Asqav.Monitoring.create_rule(
name="p95 latency spike",
metric="latency_p95",
condition="gt",
threshold=2000,
window="5min"
)
Available Metrics
Metrics you can monitor with alert rules:
| Metric | Description | Unit |
|---|---|---|
error_rate |
Percentage of failed actions | % |
latency_avg |
Average action latency | ms |
latency_p95 |
95th percentile latency | ms |
latency_p99 |
99th percentile latency | ms |
actions_per_hour |
Action throughput rate | count/hr |
cost_per_hour |
Hourly cost accumulation | $ |
total_actions |
Cumulative action count | count |
Conditions
Comparison operators for alert rule thresholds:
| Condition | Description |
|---|---|
gt |
Greater than |
lt |
Less than |
gte |
Greater than or equal |
lte |
Less than or equal |
eq |
Equal to |
ne |
Not equal to |
Rate Limits
Set per-agent rate limits to prevent runaway behavior:
python
# Set rate limit for an agent
limit = Asqav.Monitoring.set_rate_limit(
agent_id="agent_abc123",
max_actions=1000,
window="1hr"
)
print(f"Limit: {limit.max_actions} per {limit.window}")
# Check current usage against limit
usage = Asqav.Monitoring.get_rate_usage(
agent_id="agent_abc123"
)
print(f"Used: {usage.current}/{usage.limit}")
print(f"Resets at: {usage.resets_at}")
Alert Cooldown
After an alert fires, it enters a 5-minute cooldown period. During cooldown, the same rule will not fire again even if the condition remains true. This prevents alert storms during sustained incidents.