CertSafari
    Databricks Certified Data Engineer Professional - October 9 onwards· Lessons

    Domain 4 · Lesson 25/46

    Databricks SQL Alerts: Conditions, Metric Views, and Data Quality Signals

    Use Databricks Lakehouse alerts to monitor governed business metrics, data quality and anomaly signals, usage and cost, SQL warehouse/query health, audit and security events, AI agent quality, and Lakeflow Job branching.

    10 min read
    2% of exam
    5 sources
    Published 3 Oct 2026
    Docs as of 30 Sep 2026

    What you will be able to do

    • Explain how a Databricks SQL alert evaluates a scheduled query against a condition and which statuses it can return
    • Write alert queries that use aggregations, multicolumn logic, and Unity Catalog metric views for governed business metrics
    • Configure notifications and templates, and spot alerts that were skipped because of the active-run limit
    • Tell profile alerts on data profiling metrics tables apart from anomaly detection alert rules

    Key concept

    Alert = scheduled query + condition — A Databricks SQL alert owns one SQL query. It runs that query on a schedule, tests the result against a threshold you define, and sends a notification when the result breaks it. Every monitoring use case in this objective comes down to writing the right query for this mechanism.

    1.How an alert evaluates

    An alert is the monitoring tool for the whole lakehouse. It can watch business KPIs, data quality, cost trends, and operational problems, because it watches whatever a SQL query returns. The alert editor puts every part of an alert on one screen. You write and test the query, pick the SQL warehouse that runs it, set a periodic schedule, define the condition, and choose who gets notified. You can also share the alert and open advanced settings.

    Parts of the alert editor and what each one controls
    Editor componentWhat it controls
    Query editorThe SQL whose result is evaluated
    ComputeThe SQL warehouse that runs the alert query
    ScheduleThe periodic schedule, optionally in Quartz Cron Syntax
    ConditionThe value threshold that triggers a notification; Test condition previews it
    NotificationsUsers or notification destinations to alert, plus an optional notification frequency that repeats until the alert returns to OK
    AdvancedNotify on OK, Empty result state, and the notification Template

    The condition has three parts: a value, an operator, and a threshold. The value can be the first value of a column in the result, or an aggregation such as SUM or AVERAGE across every row of one column. The threshold is a static value by default. In the documented tutorial, the alert sums the amount column of a daily taxi-fare query, triggers when the sum is greater than 4000, and runs every 5 minutes. Alerts do not accept queries with parameters, so any filter values must be written directly into the SQL.

    Current alerts differ from legacy alerts in two ways that matter on the exam. First, an evaluation can only resolve to OK, TRIGGERED, or ERROR. Second, an alert cannot point at an existing saved query: each alert owns its own query definition, which you write in the alert editor. Legacy and current alerts can run side by side while you migrate. Each alert also keeps a history of past evaluations, which you can open on its details page.

    Checkpoint 1 of 5· Check yourself

    An analyst wants to build a new Databricks SQL alert on the saved query 'Daily revenue', which already powers a dashboard. What happens?

    Sources12

    2.Alert query patterns and governed business metrics

    Choosing an aggregation in the condition changes the SQL that runs. The alert wraps your query in a common table expression and aggregates over that CTE. For example, a SUM condition on SELECT 1 AS column_name runs the following query:

    What actually runs when an alert applies a SUM aggregationsql
    WITH q AS (SELECT 1 AS column_name) SELECT SUM(column_name) FROM q

    One side effect follows from that rewrite. A custom notification body can't show the rows from before aggregation, because the alert only ever sees the aggregated result. A condition also checks only one column. When the rule depends on several columns, put the logic in the query and return a flag, then trigger the alert when the flag equals 1:

    Multicolumn condition written in the query and returned as 1 or 0sql
    SELECT CASE WHEN drafts_count > 10000 AND archived_count > 5000 THEN 1 ELSE 0 END
    FROM (
    SELECT sum(CASE WHEN is_archived THEN 1 ELSE 0 END) AS archived_count,
    sum(CASE WHEN is_draft THEN 1 ELSE 0 END) AS drafts_count
    FROM queries) data

    For governed business metrics, alert on a Unity Catalog metric view. This needs no special setup: an alert on a metric view works like an alert on any other dataset, and you reference the view by its fully qualified name in the alert query. The alert then evaluates the same governed metric definition that the rest of the organization uses, not a copy of the logic written into the alert.

    Checkpoint 2 of 5· Check yourself

    An alert uses a SUM aggregation on the amount column. Its custom template includes {{QUERY_RESULT_ROWS}}. What does the notification show?

    Checkpoint 3 of 5· Exam question

    Your team migrated a set of legacy Databricks SQL alerts to the current alert editor to consolidate monitoring for governed business-metric dashboards. When reviewing alert history after the migration, which statement about the alert status model is accurate?

    Sources31

    3.Notifications, templates, and skipped runs

    Advanced settings control what reaches people. Notify on OK sends a message when the alert recovers. Empty result state sets the status to return when the query produces no rows. Template replaces the default message. Workspace admins set up notification destinations. In the standard template editor you insert variables as {{VARIABLE_NAME}}. The Markdown editor uses @VARIABLE_NAME and supports a smaller set of variables.

    Notification template variables in the standard editor
    VariableContents
    ALERT_STATUSThe evaluated alert status
    ALERT_CONDITION / ALERT_THRESHOLDThe condition operator and the threshold
    ALERT_NAME / ALERT_URLThe alert name and the alert page URL
    QUERY_RESULT_VALUEThe query result value
    QUERY_RESULT_TABLEAn HTML table of the first 100 rows; only email destinations render HTML
    QUERY_RESULT_ROWS / QUERY_RESULT_COLSThe result rows and the column names

    Alerts compete for run slots. Each workspace allows 250 simultaneous active alert runs by default. If every slot is busy when a scheduled alert fires, that run is skipped and the alert doesn't evaluate at all. To spot this, look for gaps in the evaluation history at the scheduled time. In the typical case, all the affected alerts share one schedule. To fix it, stagger the schedules, for example 01:30, 01:32, 01:34. If the workspace hits the limit consistently, Databricks Support can raise the quota.

    Checkpoint 4 of 5· Check yourself

    Two hundred and eighty alerts are all scheduled for 01:30. Several of them show gaps in their evaluation history at that time, yet Run now works on each one. What is the recommended first fix?

    Sources2

    4.Data quality and anomaly signals

    Data quality alerts come in two forms, and they work differently. A profile alert is an ordinary Databricks SQL alert. You write a query on the profile metrics table or the drift metrics table that data profiling produces, then build an alert on that query. Use it when a statistic leaves a range, such as the fraction of missing values, or when the data drifts from a baseline. Email is the default, and you can also send to a webhook, Slack, or PagerDuty.

    Anomaly detection alert rules (Beta) don't use the SQL alert editor at all. You create them under Manage alerts in the Data Quality Monitoring UI, where each rule covers one catalog or one schema. When a monitored table in that scope becomes unhealthy, for example stale or with an unexpected drop in row count, each recipient receives one email per important unhealthy table. Creating a rule needs the MANAGE privilege at the level of its scope.

    Profile alerts compared with anomaly detection alert rules
    AspectProfile alertAnomaly detection alert rule
    What it isA Databricks SQL alertA rule in the Data Quality Monitoring UI (Beta)
    Where you set it upA SQL query on the profile metrics or drift metrics tableManage alerts > Create alert
    ScopeWhatever the query selectsA catalog (All Schemas) or one schema
    DeliveryEmail by default; webhook, Slack, or PagerDuty also possibleEmail to selected workspace users, one per important unhealthy table
    Privilege to createSame as any other SQL alertMANAGE on the schema or catalog

    Checkpoint 5 of 5· Match them up

    Match each data quality alerting setup to what it requires

    Tap a term, then the definition that fits it.

    Sources45

    Exam traps

    Each one states something that sounds right. Open it to see what is actually true.

    1. 1.Anomaly detection alerts are Databricks SQL alerts that you build on a query and run on a SQL warehouse.Why is that wrong?

      Anomaly detection alert rules are created in the Data Quality Monitoring UI. Each one covers a catalog or a schema and emails recipients about unhealthy tables. Profile alerts are the SQL-alert form.

      Covered in Data quality and anomaly signals

    2. 2.If Run now succeeds, the alert's scheduled runs must be evaluating too.Why is that wrong?

      Once all of the workspace's active alert run slots are in use, a scheduled run is skipped and never evaluates. A manual run outside that spike can still succeed.

      Covered in Notifications, templates, and skipped runs

    3. 3.An alert can use a parameterized query, and the parameters are filled in at evaluation time.Why is that wrong?

      Alerts don't support queries with parameters. Filter values have to be written into the alert's SQL.

      Covered in How an alert evaluates

    Sources

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Evaluations resolve to OK, TRIGGERED, or ERROR.”
      ↩︎ How an alert evaluates
      “Reference a Unity Catalog metric view by its fully qualified name in the alert query to monitor governed business metrics.”
      ↩︎ Alert query patterns and governed business metrics
      “Databricks SQL alerts run queries on a schedule and notify you when a condition that you define is met against the query result.”
      ↩︎ Key concept
      “alerts no longer support the UNKNOWN status from legacy alerts”
      ↩︎ Prediction
      “An existing saved SQL query cannot be reused when creating an alert.”
      ↩︎ Checkpoint
    2. 2.
      “set an aggregation across all rows of a single column, such as SUM or AVERAGE”
      ↩︎ How an alert evaluates
      “Each workspace has a default limit of 250 simultaneous active alert runs.”
      ↩︎ Notifications, templates, and skipped runs
      “Empty result state: Set a special status to return when the query returns no results.”
      ↩︎ Notifications, templates, and skipped runs
      “When all run slots are in use and a scheduled alert fires, the alert run is skipped and the alert does not evaluate.”
      ↩︎ Exam trap 2
      “Alerts do not support queries with parameters.”
      ↩︎ Exam trap 3
      “stagger alert schedules so they do not all fire at the same time”
      ↩︎ Checkpoint
    3. 3.
      “The alert wraps the original query text in a common table expression (CTE) and performs a wrapping aggregation query on it”
      ↩︎ Alert query patterns and governed business metrics
      “those variables will only display the final, post-aggregation query result.”
      ↩︎ Checkpoint
    4. 4.
      “You create a Databricks SQL query on the profile metrics table or drift metrics table.”
      ↩︎ Data quality and anomaly signals
    5. 5.
      “each recipient receives one email per important unhealthy table.”
      ↩︎ Data quality and anomaly signals
      “Each alert rule is scoped to a catalog or a specific schema.”
      ↩︎ Exam trap 1
      “To create a schema-level alert, you must have the MANAGE privilege on the schema.”
      ↩︎ Checkpoint

    Continue to page 2 of 2

    Alerting on System Tables, Audit Logs, AI Agents, and Lakeflow Job Branches

    Spotted a mistake, or was something unclear? Tell us.