Prerequisites
- A Grantex account (free tier or above)
- At least one registered agent
- Your API key (
GRANTEX_API_KEY)
Step 1: Verify Built-in Rules Are Active
Anomaly detection is enabled by default for all accounts. Verify the built-in rules are active:Step 2: Configure a Slack Channel
Create a Slack incoming webhook, then register it as a notification channel:severities array filters which alerts reach this channel. Only critical and high alerts will post to Slack in the example above.
Other Channel Types
| Type | Required Config |
|---|---|
slack | webhookUrl |
pagerduty | routingKey |
datadog | apiKey, site (e.g., datadoghq.com) |
email | to (email address), from (optional) |
webhook | url, secret (for HMAC verification) |
Step 3: Create a Custom Rule
Built-in rules cover common patterns. Create custom rules for your specific needs:Condition Parameters
| Parameter | Type | Description |
|---|---|---|
agentIds | string[] | Only monitor these agents. Omit to monitor all. |
scopes | string[] | Trigger when these scopes are accessed. Omit for any scope. |
timeWindow | string | Sliding window. Options: 5m, 15m, 1h, 6h, 24h. |
threshold | number | Event count in the window that triggers the alert. |
Step 4: Stream Events in Real Time
For automated responses, connect to the SSE event stream:curl:
Step 5: Monitor via Dashboard
Open the developer portal at/dashboard/anomalies to see:
- Severity overview — Color-coded counts of open alerts by severity
- Activity chart — 14-day bar chart showing alert volume trends
- Alert list — Filter by status (open / acknowledged / resolved) and severity
- Rule builder — View, create, and toggle rules at
/dashboard/anomalies/rules
Troubleshooting
No alerts are firing
- Check that rules are enabled —
GET /v1/anomalies/rulesand verifyenabled: true - Check that agents are active — Anomaly detection only monitors active agents
- Check the time window — Rules only fire when the threshold is exceeded within the configured window
- Verify grant activity — At least some authorization events must occur for rules to evaluate
Slack notifications not arriving
- Verify the webhook URL — Test it with a manual
curlPOST - Check channel severities — The alert severity must match the channel’s
severitiesfilter - Check channel status —
GET /v1/anomalies/channelsand verifyenabled: true
Too many false positives
- Increase thresholds — Raise the
thresholdvalue for noisy rules - Narrow scope filters — Add
agentIdsorscopesto limit which events the rule evaluates - Disable low-value rules — Toggle off rules like
off_hours_activityif your agents intentionally run 24/7
Custom rule not creating
- Rule ID must be unique — Check it does not conflict with a built-in rule ID
- Valid time window — Must be one of
5m,15m,1h,6h,24h - Threshold must be positive — Must be an integer >= 1
Related
- Anomaly Detection Overview — Full feature reference
- Event Streaming — SSE and WebSocket endpoints
- Budget Controls — Financial guardrails for agents
- Security Best Practices — Defense-in-depth for agents