cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Improvement in DAB for alert_task

TPI_PARIS
New Contributor

Hello,

I'm facing with a difference between DAB and the UI concerning alert_task on job ressource.

I have an alert with a SQL query using some parameters, installed by DAB. When I want to use it un job ressource in DAB we can't use "parameters" in alert_task so we can't override these parameters. But when I create a job ressource with the UI using the same alert I can override parameters.

Any help or improvement in DAB ?

Exemple :

simple alert yaml

resources:
alerts:
generic_alert_notification:
display_name: generic_alert_notification
warehouse_id: ${var.warehouse_id}
query_text: SELECT :task as TACHE
parameters:
- name: task
value : DEFAULT TASK
evaluation:
comparison_operator: IS_NOT_NULL
source:
name: TACHE
notification:
subscriptions:
- user_email: ${var.mail_alert_1}
schedule:
pause_status: PAUSED
quartz_cron_schedule: "0 0 9 * * ?"
timezone_id: "Europe/Paris"
custom_summary: "[${var.domain_name}][${bundle.target}] Notes on {{QUERY_RESULT_VALUE}}"
custom_description: |
<b>Domaine : </b><br>
<b>Environnement : ${bundle.target}</b><br>
<b>Tรขche : {{QUERY_RESULT_VALUE}}</b><br>
<br>
<b>------------------------------------------</b><br>

simple job using alert with parameters (doesn't work)

resources:
jobs:
test_alert:
name: test notif
tasks:
- task_key: alert_gen_ko
alert_task:
alert_id: ${resources.alerts.generic_alert_notification.id}
parameters:
task: OVERIDE TASK NAME
queue:
enabled: true

 

1 REPLY 1

emma_s
Databricks Employee
Databricks Employee

Hi,
This is a known limitation today. The official documentation for the SQL alert task confirms it under the Limitations section:
"SQL alert tasks do not support parameters. If you need to use parameterised queries, consider using a SQL task instead."
So the behaviour you are seeing is expected, not a misconfiguration on your side. The alert_task schema in DABs only supports alert_id, subscribers, warehouse_id, and workspace_path. There is no parameters field available yet.
The docs suggest using a sql_task as a workaround, but that is not really equivalent. A sql_task runs a query but does not evaluate alert conditions or send subscriber notifications with custom templates (custom_summary, custom_description, {{QUERY_RESULT_VALUE}}). So it would not give you the same behaviour as your alert.
Realistic options for now:
  1. Create separate alerts per task name rather than one generic parameterised alert. Not ideal if you have many task names, but it works today with DABs.
  2. Use the UI to create the job with alert task parameter overrides (as you have already found this works), and manage that specific job outside of DABs for now.
  3. Submit product feedback directly from your workspace. Click your username icon in the top navigation bar, then click "Send feedback". Describing this gap between the UI and DABs for alert task parameters will help the product team prioritise it. There is a good chance this is already being built but all feedback helps!
Hope that helps!

 

 
resources:
  jobs:
    test_alert:
      name: test notif
      tasks:
        - task_key: alert_gen_ko
          sql_task:
            warehouse_id: ${var.warehouse_id}
            query:
              query_id: <your_query_id>
            parameters:
              task: OVERRIDE TASK NAME
      queue:
        enabled: true

 
You would need to handle the notification/alerting logic separately (e.g. via job-level notifications or a downstream condition task).