Alerts: Monitoring Query Results Automatically
Who this is for:
Architecture / Concept Overview: Alerts: Monitoring Query Results Automatically
An alert binds a saved query to a schedule and a condition. On each evaluation, Databricks runs the query, evaluates the condition against the result, and dispatches notifications if the alert triggers.
%%{init: {"theme":"base","themeVariables":{"background":"#0B0E14","primaryTextColor":"#E0E6ED","lineColor":"#5D6470","darkMode":true,"primaryColor":"#2E4A4A","secondaryColor":"#374151","secondaryTextColor":"#E0E6ED","tertiaryColor":"#111827","tertiaryTextColor":"#E0E6ED","edgeLabelBackground":"#1f2937"}}}%%
flowchart LR
classDef source fill:#3F4B59,stroke:#9CA3AF,stroke-width:2px,rx:8,ry:8,color:#E0E6ED
classDef ingestion fill:#5A4B36,stroke:#C9A86B,stroke-width:2px,rx:8,ry:8,color:#E0E6ED
classDef processing fill:#535072,stroke:#8E82B4,stroke-width:2px,rx:8,ry:8,color:#E0E6ED
classDef storage fill:#2E4A4A,stroke:#5FAFA8,stroke-width:2px,rx:8,ry:8,color:#E0E6ED
classDef serving fill:#3D5550,stroke:#6BB7AA,stroke-width:2px,rx:8,ry:8,color:#E0E6ED
classDef governance fill:#5A3F52,stroke:#C28BB0,stroke-width:2px,rx:8,ry:8,color:#E0E6ED
SCHED[Scheduler] -->|Triggers| QUERY[Saved SQL Query]
QUERY -->|Executes on| WH[SQL Warehouse]
WH -->|Returns result| EVAL[Condition Evaluator]
EVAL -->|Condition met| NOTIFY[Notification Destinations]
NOTIFY --> EMAIL[Email]
NOTIFY --> SLACK[Slack]
NOTIFY --> WEBHOOK[Webhook]
SCHED:::source
QUERY:::processing
WH:::processing
EVAL:::governance
NOTIFY:::ingestion
EMAIL:::serving
SLACK:::serving
WEBHOOK:::serving
*Figure 1 — Alert execution flow: schedule triggers query, evaluator checks condition, and notifications dispatch on trigger.*
Alerts have three states that determine notification behaviour.
%%{init: {"theme":"base","themeVariables":{"background":"#0B0E14","primaryTextColor":"#E0E6ED","lineColor":"#5D6470","darkMode":true,"primaryColor":"#2E4A4A","secondaryColor":"#374151","secondaryTextColor":"#E0E6ED","tertiaryColor":"#111827","tertiaryTextColor":"#E0E6ED","edgeLabelBackground":"#1f2937"}}}%%
graph TD
classDef source fill:#3F4B59,stroke:#9CA3AF,stroke-width:2px,rx:8,ry:8,color:#E0E6ED
classDef ingestion fill:#5A4B36,stroke:#C9A86B,stroke-width:2px,rx:8,ry:8,color:#E0E6ED
classDef processing fill:#535072,stroke:#8E82B4,stroke-width:2px,rx:8,ry:8,color:#E0E6ED
classDef storage fill:#2E4A4A,stroke:#5FAFA8,stroke-width:2px,rx:8,ry:8,color:#E0E6ED
classDef serving fill:#3D5550,stroke:#6BB7AA,stroke-width:2px,rx:8,ry:8,color:#E0E6ED
classDef governance fill:#5A3F52,stroke:#C28BB0,stroke-width:2px,rx:8,ry:8,color:#E0E6ED
OK[OK State<br/>Condition not met] -->|Condition becomes true| TRIGGERED[Triggered State<br/>Notifications sent]
TRIGGERED -->|Condition becomes false| OK
TRIGGERED -->|Query fails| UNKNOWN[Unknown State<br/>Evaluation error]
UNKNOWN -->|Query succeeds + condition false| OK
UNKNOWN -->|Query succeeds + condition true| TRIGGERED
OK:::serving
TRIGGERED:::ingestion
UNKNOWN:::source
*Figure 2 — Alert state machine: OK, Triggered, and Unknown states with transition conditions.*
Key Terms
Prerequisites and Setup
- A saved SQL query that returns a single row with the metric you want to monitor
- A running SQL warehouse
- At least one notification destination configured (workspace admin can set up Slack and webhook destinations)
CAN RUNprivilege on the underlying query andCAN USEon the warehouse
Step-by-Step Implementation
Configuration Reference
| Setting | Options | Default | Notes |
|---|---|---|---|
| Trigger condition operator | >, >=, <, <=, ==, != | > | Applied to a column in the first row of results |
| Schedule interval | 1 min to 24 hours | 1 hour | Shorter intervals consume more DBUs |
| Notification frequency | Every evaluation / Just once | Every evaluation | "Just once" stops after first trigger until state returns to OK |
| Notification destinations | Email, Slack, Webhook | None | Configure at least one destination |
| Owner run-as | Alert owner | Creator | Queries run with the owner's permissions |