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

    Domain 4 · Lesson 25/46

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

    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.

    14 min read
    2% of exam
    11 sources
    Published 3 Oct 2026
    Docs as of 30 Sep 2026

    What you will be able to do

    • Write alert queries on system.billing.usage to catch unexpected spend
    • Monitor SQL warehouse and query health from system.query.history and system.compute.warehouse_events
    • Alert on security and Genie Agent activity from system.access.audit, and identify the documented route to AI agent quality signals
    • Run a Databricks SQL alert as a Lakeflow Jobs task, and branch downstream work with If/else and Run if dependencies

    1.Usage and cost alerts on system.billing.usage

    A Databricks SQL alert runs a query on a schedule and sends a notification when the result crosses a threshold. System tables expose platform telemetry as queryable tables, so one alert mechanism can also watch spend, warehouses, security events, and jobs. Start with cost. Users who have access to system tables can query billing records in system.billing.usage. In each record, usage_metadata identifies the resource involved, identity_metadata identifies the user or service principal, and billing_origin_product and product_features identify the product. custom_tags holds compute tags.

    The answer is custom_tags. It includes tags added by serverless usage policies, which is how serverless usage gets attributed to a team. For alerts, choose a documented sample that has no parameters, since alerts can't take them. One example is the ranking of jobs by DBU usage:

    Jobs ranked by DBU consumption, a parameter-free query an alert can watchsql
    SELECT
      usage_metadata.job_id as `Job ID`, sum(usage_quantity) as `Usage`
    FROM
      system.billing.usage
    WHERE
      usage_metadata.job_id IS NOT NULL
    GROUP BY
      `Job ID`
    ORDER BY
      `Usage` DESC

    Because this query sorts the heaviest job to the top, a condition on the first value of Usage checks the most expensive job. Several other billing samples use bind variables such as custom_tags [:key] = :value or :usage_start_time. Before using one of those as an alert, write the values directly into the SQL.

    Checkpoint 1 of 8· Check yourself

    Which system.billing.usage column lets you attribute serverless spend using tags from serverless usage policies?

    Checkpoint 2 of 8· Exam question

    A platform team wants an early-warning alert when a single workspace's daily DBU spend exceeds a threshold, broken down by the job that generated the usage. Which two actions correctly use Databricks system tables and SQL alerts to support this? (Choose 2)(Select 2)

    Sources12

    2.SQL warehouse and query health

    Alerts on warehouse events or query history catch slow queries, failed sessions, and capacity problems. Four system tables cover this area, and Databricks publishes example queries for them that you can turn into alerts.

    System tables for monitoring SQL warehouses
    System tableWhat it records
    system.compute.warehouse_eventsWarehouse start, stop, scale-up, and scale-down events
    system.compute.warehousesSnapshots of warehouse configurations
    system.query.historyDetails of every query executed on SQL warehouses
    system.billing.usageBilling records for all Databricks usage
    Recent queries on one warehouse with duration, status, and time spent waiting at capacitysql
    SELECT
      statement_id,
      executed_by,
      statement_type,
      execution_status,
      total_duration_ms,
      execution_duration_ms,
      compilation_duration_ms,
      waiting_at_capacity_duration_ms,
      read_rows,
      produced_rows,
      start_time,
      statement_text
    FROM
      system.query.history
    WHERE
      compute.warehouse_id = '<warehouse-id>'
      AND start_time >= NOW() - INTERVAL 1 DAY

    Each column answers a different health question. total_duration_ms shows slow queries, execution_status shows failures, and waiting_at_capacity_duration_ms shows queries that waited because the warehouse was full. An alert set on one of these values tells you when it moves into a range you didn't expect.

    Checkpoint 3 of 8· Check yourself

    You want to know when a warehouse keeps scaling up. Which system table records that event?

    Sources13

    3.Audit and security events

    For security monitoring, alert on audit log queries. The audit log system table, system.access.audit (Public Preview), records user_identity, service_name, action_name, request_params, response, and source_ip_address. Keep a few details in mind:

    - Filter on event_date rather than event_time for better performance. - Account-level events record workspace_id as 0. - Most audit logs are only available in the region of the workspace. - Some request_params keys that hold SQL definitions are hidden unless you are an account admin or a member of databricks_pii_access.

    The documented example monitors Genie Agents, formerly called Genie Spaces. You can then set an alert to automate the check.

    Checkpoint 4 of 8· Fill the gap

    This query returns Genie Agent feedback ratings from the last 30 days. Which service name completes it?

    SELECT
      user_identity.email as user_email,
      action_name,
      request_params.space_id,
      request_params.feedback_rating,
      *
    FROM
      system.access.audit
    WHERE
      service_name = ' ? '
      AND action_name = 'updateConversationMessageFeedback'
      AND event_date >= current_date() - interval 30 days

    Sources145

    4.AI agent quality

    The alerts overview lists agents as a target: alert on agent quality metrics so that failures and new issues come to light during development and in operation. The agent observability docs describe where those metrics come from. Production monitoring runs MLflow scorers on agent traces and attaches the results to each evaluated trace as feedback. Traces stored in Unity Catalog are governed and queryable with SQL.

    These sources name the pattern but don't include a sample alert query on scorer results. Treat it as the general rule applied to agents: write a SQL query that returns a quality metric, then put an alert condition on it. The Genie feedback-rating audit query from the previous section is one documented, alertable signal of agent quality from users.

    Checkpoint 5 of 8· Check yourself

    With MLflow production monitoring on an agent, where do the scorer results end up?

    Sources167

    5.Alerts as tasks in Lakeflow Jobs, and branching

    An alert can also run as a task in Lakeflow Jobs. The condition check then happens as part of a pipeline run instead of on a clock. The task needs an existing Databricks SQL alert, CAN RUN permission on that alert, and a serverless or pro SQL warehouse. The task evaluates the alert separately from the alert's own schedule, which the job run leaves untouched. Alert tasks don't support parameters, and they don't support legacy alerts.

    Checkpoint 6 of 8· Put it in order

    Put the steps for adding a SQL alert task to a new job in order

    1. 1.Click Create, then Job
    2. 2.Click Add another task type, search for SQL Alert, and select the tile
    3. 3.Enter a Task name
    4. 4.Click Jobs & Pipelines in the sidebar
    5. 5.Select the Databricks SQL alert from the Alert drop-down menu
    An alert (v2) task defined in Declarative Automation Bundlesyaml
    resources:
      jobs:
        my_job:
          name: my_job
          tasks:
            - task_key: alert_task
              alert_task:
                workspace_path: ./my_alert.dbalert.json
                warehouse_id: 1a111111a1111aa1

    Lakeflow Jobs provides two ways to branch. Run if dependencies run a task based on whether upstream tasks succeeded, failed, or completed. The If/else condition task tests a boolean expression whose operands can reference job parameters, task parameters, or task values such as {{tasks.<task_name>.values.<value_name>}}. Downstream tasks depend on <task-name> (true) or <task-name> (false). Operator choice matters. == and != compare their operands as strings, so 12.0 == 12 is false. >, >=, <, and <= compare them as numbers. The condition task doesn't need a cluster, and it supports neither retries nor notifications.

    Checkpoint 7 of 8· Fill the gap

    In this bundle, notebook_task should run only while the job's repair count is below 5. Which operator completes the condition?

    resources:
      jobs:
        my-job:
          name: my-job
          tasks:
            - task_key: condition_task
              condition_task:
                op:  ? 
                left: '{{job.repair_count}}'
                right: '5'
            - task_key: notebook_task
              depends_on:
                - task_key: condition_task
                  outcome: 'true'
              notebook_task:
                notebook_path: ../src/notebook.ipynb

    Checkpoint 8 of 8· Exam question

    A security engineer must be alerted whenever a Unity Catalog grant is modified outside business hours across any workspace in the account. Which two design choices correctly use Databricks system tables and SQL alerts to satisfy this? (Choose 2)(Select 2)

    Sources18910

    Exam traps

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

    1. 1.A SQL alert task fails when its alert condition is met, so a Run if dependency on failure catches triggered alerts.Why is that wrong?

      The task reports Succeeded whether or not the condition triggered. It reports Failed only when evaluation errors, for example a warehouse connection problem or a query error.

      Covered in Alerts as tasks in Lakeflow Jobs, and branching

    2. 2.An If/else condition of {{tasks.check.values.score}} == 12 is true when the task value is 12.0.Why is that wrong?

      == and != compare their operands as strings, so 12.0 == 12 evaluates to false. Use a numeric operator such as >= when the comparison has to be numeric.

      Covered in Alerts as tasks in Lakeflow Jobs, and branching

    3. 3.Adding an alert to a job as a SQL alert task replaces the alert's own schedule.Why is that wrong?

      The task evaluates the alert separately, and the schedule on the underlying alert keeps running unchanged.

      Covered in Alerts as tasks in Lakeflow Jobs, and branching

    Practise it for real

    Build a cost alert on system.billing.usage and run it as a SQL alert task in a Lakeflow job

    1. 1.Click Alerts in the sidebar, then click Create Alert. Paste the jobs-by-DBU query (SELECT usage_metadata.job_id ... FROM system.billing.usage ... ORDER BY Usage DESC) and click Run all.

      Why: The alert owns its query, and this sample has no parameters, which alerts don't support.

      You should see: A result table of job IDs, sorted by Usage from highest to lowest.

    2. 2.Pick a SQL warehouse in the compute selector. In Condition, choose the first value of the Usage column, the > operator, and a static threshold of your choice.

      Why: Because the query sorts descending, the first value is the most expensive job.

      You should see: The condition panel shows Usage > your threshold.

    3. 3.Click Test condition, then lower the threshold until the alert would trigger.

      Why: This confirms the condition logic before any notification goes out.

      You should see: The preview reports TRIGGERED at a low threshold and OK at a high one.

    4. 4.Add yourself under Notifications, set a schedule with the calendar icon, and click View alert.

      Why: A saved, scheduled alert is required before a job can use it.

      You should see: The details page shows the alert and its evaluation history, plus a Run now button.

    5. 5.In Jobs & Pipelines, click Create, then Job. Add a SQL Alert task, select your alert, and choose a serverless or pro SQL warehouse. Run the job.

      Why: Running the alert as a task moves the check into a pipeline run, independent of the alert's own schedule.

      You should see: The task reports Succeeded whether your alert evaluated to OK or TRIGGERED.

    Stuck? Get a nudge

    If the job task shows Failed, check the warehouse type and your CAN RUN permission on the alert. Failed means evaluation errored; it never means the condition was met.

    Sources

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

    1. 1.
      “Build alerts on system tables for serverless billing or ingestion to catch unexpected spend.”
      ↩︎ Usage and cost alerts on system.billing.usage
      “Alert on warehouse events or query history to catch slow queries, failed sessions, or capacity issues.”
      ↩︎ SQL warehouse and query health
      “Alert on audit log queries to flag unusual workspace activity.”
      ↩︎ Audit and security events
      “Alert on agent quality metrics so failures and emerging issues surface during development and operation.”
      ↩︎ AI agent quality
      “Add an alert as a task so condition checks run on a pipeline trigger and downstream tasks can branch on the result.”
      ↩︎ Alerts as tasks in Lakeflow Jobs, and branching
    2. 2.
      “You can also add alerts to your queries to help you stay informed about usage data.”
      ↩︎ Usage and cost alerts on system.billing.usage
      “This also includes tags added by serverless usage policies so you can attribute serverless usage.”
      ↩︎ Checkpoint
    3. 3.
      “Add alerts to get notified of unexpected values.”
      ↩︎ SQL warehouse and query health
      “Tracks warehouse start, stop, scale-up, and scale-down events.”
      ↩︎ Checkpoint
    4. 4.
      “To improve query performance, filter on event_date rather than event_time.”
      ↩︎ Audit and security events
      “Those keys are omitted unless you are an account admin or a member of the databricks_pii_access account-level group”
      ↩︎ Audit and security events
    5. 5.
      “You can set alerts to help automate this type of monitoring.”
      ↩︎ Audit and security events
    6. 6.
      “Results are attached as feedback to each evaluated trace.”
      ↩︎ AI agent quality
    7. 7.
      “governed, SQL-queryable, and the data foundation for everything else”
      ↩︎ AI agent quality
    8. 8.
      “You must have at least CAN RUN permission on the alert you want to use.”
      ↩︎ Alerts as tasks in Lakeflow Jobs, and branching
      “Failed: An error occurred during alert evaluation, such as a SQL warehouse connectivity issue or a query error.”
      ↩︎ Exam trap 1
      “The SQL alert task evaluates the alert independently from any schedule configured on the alert itself.”
      ↩︎ Exam trap 3
      “Click Add another task type. Search for SQL Alert and click the tile to select it.”
      ↩︎ Checkpoint
      “The alert was evaluated successfully, regardless of whether the alert condition was triggered or not.”
      ↩︎ Prediction
    9. 9.
      “The Run if dependencies field allows you to add control flow logic to tasks based on other tasks' success, failure, or completion.”
      ↩︎ Alerts as tasks in Lakeflow Jobs, and branching
    10. 10.
      “The condition task does not require a cluster to execute and does not support retries or notifications.”
      ↩︎ Alerts as tasks in Lakeflow Jobs, and branching

    Also cited

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