Skip to main content

Alert Rules Guide

Set up intelligent alerts to monitor your time-series data and get notified when important events occur.

What are Alert Rules?

Alert rules continuously monitor your incoming data and trigger notifications when specified conditions are met. With dakkio, you can write alert conditions in plain English using natural language queries.

Creating Your First Alert

Step 1: Define the Condition

Think about what you want to monitor:

  • "Temperature exceeds 30°C for 5 minutes"
  • "Humidity drops below 40% for 10 minutes"
  • "Battery level is less than 20%"
  • "No data received for 30 minutes"

Step 2: Create via Dashboard

  1. Navigate to your bucket
  2. Go to the "Alerts" tab
  3. Click "Create Alert Rule"
  4. Enter details:
    • Name: "High Temperature Warning"
    • Data Source: Select your sensor
    • Condition: "Temperature exceeds 30°C for 5 minutes"
    • Cooldown: 15 minutes
  5. Click "Create"

Step 3: Create via API

curl -X POST https://api.dakkio.io/api/alerts \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"bucketId": "507f1f77bcf86cd799439011",
"dataSourceId": "507f1f77bcf86cd799439012",
"name": "High Temperature Warning",
"naturalLanguageQuery": "Temperature exceeds 30°C for 5 minutes",
"cooldownMinutes": 15
}'

Natural Language Syntax

Comparison Operators

"temperature exceeds 30"
"temperature is greater than 30"
"humidity is less than 40"
"humidity drops below 40"
"pressure equals 1013"
"battery is not equal to 0"

Duration Conditions

"temperature > 30 for 5 minutes"
"humidity < 40 for 10 minutes"
"pressure > 1020 for 1 hour"

No Data Alerts

"no data received for 30 minutes"
"no readings for 1 hour"
"missing data for 2 hours"

How Alerts Work

Alert Lifecycle

  1. Monitoring: Alert engine checks every new data point
  2. Triggered: Condition is met, webhooks are called
  3. Cooldown: Alert cannot trigger again for the cooldown period
  4. Reset: After cooldown, alert can trigger again

Cooldown Periods

Cooldown prevents alert spam by ensuring alerts don't trigger too frequently.

Example:

{
"cooldownMinutes": 15
}
  • Alert triggers at 10:00 AM
  • Cannot trigger again until 10:15 AM
  • Even if condition remains true, only one notification sent

Best Practices:

  • Use 5-15 minutes for high-priority alerts
  • Use 30-60 minutes for informational alerts
  • Use longer cooldowns for non-critical issues

Alert States

Active

Alert is monitoring and can trigger.

Paused

Alert is temporarily disabled but configuration is preserved.

Inactive

Alert is disabled and won't trigger.

Common Alert Patterns

Temperature Monitoring

// High temperature
{
"naturalLanguageQuery": "Temperature exceeds 30°C for 5 minutes",
"cooldownMinutes": 15
}

// Low temperature
{
"naturalLanguageQuery": "Temperature drops below 10°C",
"cooldownMinutes": 30
}

// Rapid change
{
"naturalLanguageQuery": "Temperature changes by more than 5°C in 1 minute",
"cooldownMinutes": 10
}

Environmental Monitoring

// High humidity
{
"naturalLanguageQuery": "Humidity exceeds 80% for 30 minutes",
"cooldownMinutes": 60
}

// Low humidity
{
"naturalLanguageQuery": "Humidity is less than 30%",
"cooldownMinutes": 30
}

Device Health

// Low battery
{
"naturalLanguageQuery": "Battery level is less than 20%",
"cooldownMinutes": 60
}

// No connectivity
{
"naturalLanguageQuery": "No data received for 15 minutes",
"cooldownMinutes": 5
}

Advanced Examples

Multiple Conditions (Coming Soon)

// AND condition
{
"naturalLanguageQuery": "Temperature > 30 AND humidity < 40"
}

// OR condition
{
"naturalLanguageQuery": "Temperature > 35 OR humidity > 90"
}

Time-Based Alerts (Coming Soon)

// Only alert during business hours
{
"naturalLanguageQuery": "Temperature > 25 between 9am and 5pm"
}

// Only alert on weekdays
{
"naturalLanguageQuery": "Humidity < 40 on weekdays"
}

Testing Alerts

1. Send Test Data

Send data that should trigger your alert:

curl -X POST https://api.dakkio.io/api/data \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"bucketId": "507f1f77bcf86cd799439011",
"dataSourceId": "507f1f77bcf86cd799439012",
"values": { "temperature": 35 }
}'

2. Check Webhook Delivery

If alert triggers, webhook should receive:

{
"event": "alert.triggered",
"timestamp": "2024-01-15T10:30:00Z",
"data": {
"alertId": "507f1f77bcf86cd799439015",
"alertName": "High Temperature Warning",
"bucketId": "507f1f77bcf86cd799439011",
"dataSourceId": "507f1f77bcf86cd799439012",
"condition": "Temperature exceeds 30°C",
"currentValue": 35,
"threshold": 30,
"dataPoint": {
"timestamp": "2024-01-15T10:30:00Z",
"values": { "temperature": 35 }
}
}
}

3. Verify in Dashboard

Check the alert history in your dashboard to see trigger times and values.

Best Practices

1. Start Conservative

Begin with loose thresholds and adjust based on real data:

// ❌ TOO STRICT: Will trigger constantly
{ "naturalLanguageQuery": "Temperature > 20°C" }

// ✅ GOOD: Reasonable threshold
{ "naturalLanguageQuery": "Temperature > 30°C for 5 minutes" }

2. Use Appropriate Cooldowns

// Critical alerts: Short cooldown
{ "cooldownMinutes": 5 }

// Warning alerts: Medium cooldown
{ "cooldownMinutes": 15 }

// Informational: Long cooldown
{ "cooldownMinutes": 60 }

3. Name Descriptively

// ❌ BAD: Vague
{ "name": "Alert 1" }

// ✅ GOOD: Clear purpose and threshold
{ "name": "High Temperature Warning (>30°C)" }

4. Include Duration for Noise Reduction

// ❌ BAD: Triggers on any spike
{ "naturalLanguageQuery": "Temperature > 30" }

// ✅ GOOD: Sustained high temperature
{ "naturalLanguageQuery": "Temperature > 30 for 5 minutes" }

5. Set Up Graduated Alerts

// Warning level
{
"name": "Temperature Warning",
"naturalLanguageQuery": "Temperature > 30°C for 5 minutes",
"cooldownMinutes": 15
}

// Critical level
{
"name": "Temperature Critical",
"naturalLanguageQuery": "Temperature > 35°C for 2 minutes",
"cooldownMinutes": 5
}

Troubleshooting

Alert Not Triggering

  1. Check alert status: Ensure it's "active", not "paused"
  2. Verify data source: Confirm data is being ingested
  3. Check condition syntax: Review natural language query
  4. Check cooldown: Alert may still be in cooldown period
  5. Verify webhook: Ensure webhook URL is reachable

Too Many Alerts

  1. Increase cooldown: Give more time between triggers
  2. Add duration: Require sustained conditions
  3. Adjust threshold: Make condition more strict
  4. Pause during maintenance: Temporarily disable alerts

Alert Delayed

  1. Check ingestion timing: Alerts trigger on data arrival
  2. Review duration: Duration conditions require time to pass
  3. Network latency: Consider time for webhooks to deliver

Monitoring Alert Health

Track alert effectiveness:

{
"triggeredCount": 15, // Times alert triggered
"lastTriggeredAt": "2024-01-15T10:30:00Z",
"cooldownMinutes": 15,
"status": "active"
}

Next Steps

Need Help?