The number crossed the threshold, but nobody got an email. Or the Teams channel gets the same alert every five minutes even though nothing is wrong. Databricks SQL alerts have only a few moving parts: a query, a condition, a schedule, an identity and some subscribers. When one goes wrong, it's almost always one of those five. This page works through them in order.
Symptom to cause
| Symptom | Likely cause | Fix |
|---|---|---|
Never triggers, state stays OK | Wrong column or aggregation, wrong operator, threshold in the wrong units | Fix the condition, then click Test condition |
| Triggers on every run | Operator reversed, or Empty result state set to TRIGGERED on a query that often returns nothing | Correct the operator or change the empty result state |
State is ERROR | Query fails, run-as identity lost access, warehouse deleted, or an empty result with no empty result state set | Read error_message in the evaluation history |
| Triggered, but no message arrived | No subscribers, broken destination, or the alert was already triggered and doesn't re-notify | Check notified_subscriptions / failed_subscriptions and the re-notify setting |
| Some scheduled runs never happen | Schedule paused, wrong time zone, or the workspace limit on active alert runs was hit | Check schedule.pause_status and stagger schedules |
| Worked for months, then stopped | The owner or run-as user left, or a table was moved or renamed | Change the owner or run-as to a service principal and re-grant access |
Step 1: read the evaluation history
Don't start in the UI. The system.alert schema records every evaluation, including the state it produced and whether each notification was delivered.
-- Last 7 days of evaluations for one alert
SELECT start_time,
end_time,
evaluated_state,
evaluated_source_result,
evaluated_threshold_result,
error_code,
error_message,
notified_subscriptions,
failed_subscriptions
FROM system.alert.alert_evaluation_history
WHERE alert_id = '<alert-id>'
AND start_time >= current_timestamp() - INTERVAL 7 DAYS
ORDER BY start_time DESC;
The alert ID is in the alert's URL. Records usually show up within an hour, so this won't show the run that just happened.
By default, only users who are both account admin and metastore admin can read these tables. If the schema is missing or access is denied, see system tables missing, empty or access denied.
Use the results to narrow down the cause:
evaluated_source_resultis the value the alert actually computed. If it's not what you expected, the condition is wrong (step 2).evaluated_state = 'ERROR'with anerror_messageis a query or permission problem (step 3).TRIGGEREDwith an emptynotified_subscriptionsis a notification problem (step 4).- Missing rows where you expected runs is a schedule problem (step 5).
Step 2: fix the condition
A condition has four parts:
- Data value to check: the first value of a column, or an aggregation over all rows of that column, such as SUM or AVERAGE.
- Column: the result column to check.
- Operator: the comparison, such as greater than, less than or equal.
- Threshold: a static value or another column.
Common mistakes:
- First value on an unordered query. If the query returns many rows and the alert checks the first value, the result depends on row order. Either aggregate in SQL and return one row, or add
ORDER BY. - Units. The query returns failure percent (
4.2) but the threshold assumes a fraction (0.05), or the other way round. - Operator reversed. "Alert when free capacity is low" needs less than, not greater than.
Make the query return exactly the number the alert should check. That's easier to test than an aggregation configured in the UI:
-- Alert query: failed job runs in the last hour (returns one row)
SELECT count(*) AS failed_runs
FROM system.lakeflow.job_run_timeline
WHERE result_state = 'FAILED'
AND period_end_time >= current_timestamp() - INTERVAL 1 HOUR;
Set the condition to failed_runs, first value, greater than 0. Then click Test condition. It runs against current data and shows whether the alert would trigger.
Tip
A
count(*)query always returns one row, even when nothing matches. A query that returns detail rows returns nothing on a quiet day, and then the Empty result state decides the outcome. Prefer aggregates for alert queries.
Empty result state
If the query returns no rows and no empty result state is set, the alert goes to ERROR. Choose the state deliberately:
| Query returns nothing means... | Set Empty result state to |
|---|---|
| All good (no failures found) | OK |
| Something is wrong (expected heartbeat rows are missing) | TRIGGERED |
| You want to know the alert itself is broken | ERROR |
Step 3: fix ERROR state
Look up the error_message from step 1. Most errors fall into one of these groups:
TABLE_OR_VIEW_NOT_FOUND/PERMISSION_DENIED. The run-as identity can't read the table. Check who that is:
SELECT alert_id, display_name, owned_by, run_as, compute
FROM system.alert.alerts
WHERE alert_id = '<alert-id>'
QUALIFY row_number() OVER (PARTITION BY workspace_id, alert_id ORDER BY change_time DESC) = 1;
run_as is the user or service principal whose credentials run the query. Grant it access:
GRANT USE CATALOG ON CATALOG prod TO `<run-as-principal>`;
GRANT USE SCHEMA ON SCHEMA prod.ops TO `<run-as-principal>`;
GRANT SELECT ON TABLE prod.ops.job_health TO `<run-as-principal>`;
- Warehouse problems. The warehouse in
computewas deleted, or the run-as identity has no permission to use it. Give it Can use on the warehouse, or point the alert at a different warehouse. - Query timeout. A heavy alert query that runs every few minutes hits
STATEMENT_TIMEOUTor competes with dashboards. Pre-aggregate into a small table or materialized view and alert on that.
If owned_by is Unavailable, the owner's user was deleted. Transfer ownership through the alert's sharing settings and set run-as to a service principal so it doesn't happen again.
Step 4: fix missing notifications
Find triggered evaluations that didn't notify anyone, or where a delivery failed:
SELECT start_time, evaluated_state, notified_subscriptions, failed_subscriptions
FROM system.alert.alert_evaluation_history
WHERE alert_id = '<alert-id>'
AND evaluated_state = 'TRIGGERED'
AND start_time >= current_timestamp() - INTERVAL 7 DAYS
ORDER BY start_time DESC;
Then check the alert's settings:
SELECT display_name, notify_on_ok, retrigger_seconds, subscriptions
FROM system.alert.alerts
WHERE alert_id = '<alert-id>'
QUALIFY row_number() OVER (PARTITION BY workspace_id, alert_id ORDER BY change_time DESC) = 1;
| Finding | Meaning | Fix |
|---|---|---|
subscriptions empty | Nobody is subscribed | Add users or a notification destination |
failed_subscriptions not empty | The destination rejected the message | An admin checks the destination (webhook URL, Teams/Slack configuration) in the workspace admin settings (Notifications tab) |
retrigger_seconds = 0 | The alert notifies only when it changes to TRIGGERED, not while it stays triggered | Set a notification frequency if on-call needs reminders |
| Recovery messages missing | Notify on OK is off | Turn it on |
Only workspace admins can create notification destinations. Teams can subscribe to any destination that already exists. Send production alerts to a shared destination (on-call channel or paging webhook), not to one person's mailbox.
Warning
Personal email subscriptions disappear silently when a person leaves. For anything that pages on-call, use a destination owned by the platform team and test it with a deliberately triggered alert after every change.
Step 5: fix schedule gaps
Each alert's schedule is stored as a Quartz cron expression with a time zone:
SELECT display_name,
schedule.pause_status,
schedule.quartz_cron_schedule,
schedule.timezone_id
FROM system.alert.alerts
WHERE delete_time IS NULL
QUALIFY row_number() OVER (PARTITION BY workspace_id, alert_id ORDER BY change_time DESC) = 1
ORDER BY display_name;
pause_status = 'PAUSED'means the alert never runs. Someone may have paused it during maintenance and forgotten it.- A time zone mismatch makes a "09:00" check run at 09:00 UTC, which may be hours off from what you expect.
- Each workspace has a default limit on simultaneous active alert runs. When it's reached, scheduled runs are skipped with no evaluation. If many alerts share
0 0/5 * * * ?, spread their start minutes. Check the current limit in the documentation and ask Databricks support if you need more.
Prevent it next time
- Return one aggregated row from every alert query and set the empty result state explicitly.
- Run alerts as a service principal with only
SELECTon the tables it needs and Can use on a small dedicated warehouse. - Route production alerts to admin-owned notification destinations and turn on Notify on OK.
- Schedule a weekly check that lists alerts in
ERROR, paused alerts and alerts whose owner isUnavailable:
WITH latest AS (
SELECT alert_id, display_name, owned_by, schedule.pause_status AS pause_status
FROM system.alert.alerts
WHERE delete_time IS NULL
QUALIFY row_number() OVER (PARTITION BY workspace_id, alert_id ORDER BY change_time DESC) = 1
),
last_eval AS (
SELECT alert_id, evaluated_state, start_time
FROM system.alert.alert_evaluation_history
QUALIFY row_number() OVER (PARTITION BY alert_id ORDER BY start_time DESC) = 1
)
SELECT l.display_name, l.owned_by, l.pause_status, e.evaluated_state, e.start_time
FROM latest l LEFT JOIN last_eval e USING (alert_id)
WHERE l.owned_by = 'Unavailable'
OR l.pause_status = 'PAUSED'
OR e.evaluated_state = 'ERROR'
OR e.alert_id IS NULL;
For job failures, use job notifications rather than SQL alerts. See job alerts that reach on-call.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get