---
title: "Alert Conditions - Documentation"
description: "All condition types: thresholds, change detection, anomaly detection, and compound conditions. Examples for each."
canonical: "https://www.aifordatabase.com/docs/alert-conditions/"
---

# Alert Conditions

intermediate 5 min read

## Alert Conditions

Conditions determine when an alert fires. AI for Database supports several condition types, from simple thresholds to anomaly detection.

### Threshold Conditions

The most common condition type. Compare a query result value against a static threshold.

**Operators:**

*   Greater than (`>`)
*   Greater than or equal (`>=`)
*   Less than (`<`)
*   Less than or equal (`<=`)
*   Equals (`==`)
*   Not equals (`!=`)

**Example**: "Fire when the error count in the last hour is greater than 100."

### Row Count Conditions

Fire based on whether the query returns any rows, or a specific number of rows.

*   **Has rows** -- fires when at least one row is returned
*   **No rows** -- fires when zero rows are returned
*   **Row count threshold** -- fires when the number of rows crosses a threshold

**Example**: "Fire when there are overdue invoices" (query: "Show me invoices past due date", condition: has rows).

### Change Detection

Compare the current value to the previous run's value.

**Options:**

*   **Absolute change** -- fires when the value changes by more than N (e.g., revenue dropped by more than $5,000)
*   **Percentage change** -- fires when the value changes by more than N% (e.g., error rate increased by more than 50%)
*   **Any change** -- fires whenever the value is different from the last run

### Anomaly Detection

Available on Enterprise plans. AI for Database learns the normal pattern of your metric over time and fires when the value deviates significantly.

**Configuration:**

*   **Sensitivity** -- low, medium, or high
*   **Direction** -- alert on high anomalies, low anomalies, or both
*   **Training period** -- how much historical data to consider (7 days, 30 days, 90 days)

### Compound Conditions

Combine multiple conditions with AND or OR logic:

*   "Fire when error count > 100 AND success rate < 95%"
*   "Fire when revenue < $1,000 OR order count = 0"

Each sub-condition can use a different query, allowing you to create sophisticated multi-signal alerts.

### Condition History

Every condition evaluation is logged. View the history in the alert's **Evaluations** tab to see the value at each check, whether the condition was met, and whether a notification was sent.

Source: https://www.aifordatabase.com/docs/alert-conditions/
