Anomaly Detection & Alerts

Relay Cloud monitors your app's traffic patterns and alerts you when something looks wrong — spikes, drops, error surges, or unusual connection behavior.

Setting Up Alerts

Go to your app dashboard and open Alerts. Click New Alert Rule and configure:

  • Metric — what to monitor (connections, messages/sec, error rate, p99 latency)
  • Condition — threshold or anomaly detection
  • Notification channel — where to send alerts

Alert Types

Threshold Alerts

Fire when a metric crosses a fixed boundary:

{
    "name": "High error rate",
    "metric": "error_rate",
    "condition": {
        "operator": "greater_than",
        "value": 5,
        "unit": "percent"
    },
    "window": "5m",
    "channels": ["slack", "email"]
}

Anomaly Detection

Uses your app's historical baseline to detect unusual behavior automatically. No thresholds to configure — Relay learns what "normal" looks like.

{
    "name": "Connection anomaly",
    "metric": "connections",
    "condition": {
        "type": "anomaly",
        "sensitivity": "medium"
    },
    "channels": ["slack"]
}

Sensitivity levels: low (fewer, higher-confidence alerts), medium, high (more alerts, may include noise).

Notification Channels

Slack

Connect your Slack workspace in Settings > Integrations, then select channels:

{
    "type": "slack",
    "channel": "#relay-alerts"
}

Email

Alerts go to all organization members by default. Add specific addresses:

{
    "type": "email",
    "addresses": ["oncall@example.com"]
}

Webhook

Send alert payloads to any URL:

{
    "type": "webhook",
    "url": "https://example.com/hooks/relay-alerts",
    "headers": {
        "X-Secret": "your-webhook-secret"
    }
}

The webhook payload looks like:

{
    "alert": "High error rate",
    "metric": "error_rate",
    "current_value": 8.3,
    "threshold": 5,
    "app_id": "YOUR_APP_ID",
    "triggered_at": "2026-04-04T12:34:56Z"
}

Managing Alerts via API

# Create an alert rule
curl -X POST https://your-relay-host.com/api/v1/apps/YOUR_APP_ID/alerts \
  -H "Authorization: Bearer YOUR_APP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Message spike",
    "metric": "messages_per_second",
    "condition": { "operator": "greater_than", "value": 10000 },
    "window": "1m",
    "channels": [{ "type": "webhook", "url": "https://example.com/hook" }]
  }'

# List alert rules
curl https://your-relay-host.com/api/v1/apps/YOUR_APP_ID/alerts \
  -H "Authorization: Bearer YOUR_APP_TOKEN"

# Delete an alert rule
curl -X DELETE https://your-relay-host.com/api/v1/apps/YOUR_APP_ID/alerts/alert_abc123 \
  -H "Authorization: Bearer YOUR_APP_TOKEN"

Available Metrics

Metric Description
connections Current open WebSocket connections
messages_per_second Events published per second
error_rate Percentage of failed API calls
p99_latency 99th percentile delivery latency (ms)
subscription_count Total active channel subscriptions
auth_failure_rate Percentage of failed auth attempts