cancel
Showing results for 
Search instead for 
Did you mean: 
Get Started Discussions
Start your journey with Databricks by joining discussions on getting started guides, tutorials, and introductory topics. Connect with beginners and experts alike to kickstart your Databricks experience.
cancel
Showing results for 
Search instead for 
Did you mean: 

Set a theshold Notification on Job run time.

rwalrondNHS
New Contributor

Hello all, I am brand new to Databricks, so forgive me if this question has been answered before,  but what i want to do is set a run time threshold to my Databricks Jobs such that if the job which say normally runs for 30 minutes, runs for over an hour,  then i get an email notification.

I have found the Job-Notifications section within the Databricks Job, and I can set it there in the UI. But according to CoPilot, I cannot programmatically set this and as soon as i do a code deploy/rebuild,  the values will get removed.

Is it true that I can't set these through code and that any manual set is wiped out?

It seems a bit weird to me as it kind of makes the Ui ability worthless? I have weekly deploys by the way which would mean a manual set every week if the above is true.  Cheers all.

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Ashwin_DSA
Databricks Employee
Databricks Employee

Hi @rwalrondNHS,

You can set these thresholds and notifications programmatically. They’re part of the normal Jobs definition, not a UI‑only feature. I've just tested this for a sample job and it works perfectly.

Under the hood, the run longer than X --> send email UI maps to the below

  • health.rules with metric = RUN_DURATION_SECONDS, op = GREATER_THAN, value = <seconds>
  • email_notifications.on_duration_warning_threshold_exceeded = [ "you@example.com", ... ]

For example (Jobs API 2.1/2.2): This is the output I had from my sample job notification setting

{
  "health": {
    "rules": [
      {
        "metric": "RUN_DURATION_SECONDS",
        "op": "GREATER_THAN",
        "value": 60
      }
    ]
  },
  "email_notifications": {
    "on_duration_warning_threshold_exceeded": [
      "ashXX.XXX@XXX.com"
    ]
  }
}

If your deployment pipeline uses jobs/create or jobs/reset and doesn’t include these fields in the JSON/YAML it sends, those UI‑configured values get overwritten by whatever is in code (which in that case is "nothing"). That’s not a limitation of the feature, it’s just “"nfra as code" doing what it’s supposed to do: the code is treated as the source of truth.

So..it’s not true that you can’t set them via code. You absolutely can (and should, if you have weekly deploys). However, manual UI tweaks will be wiped if your job‑as‑code definition omits them on each deploy.

The UI is still useful for interactive editing and discovery, but in a CI/CD setup you’ll want to copy those settings into your job JSON/Terraform/Bundles config so they persist across rebuilds.

Hope this helps.

If this answer resolves your question, could you mark it as “Accept as Solution”? That helps other users quickly find the correct fix.

Regards,
Ashwin | Delivery Solution Architect @ Databricks
Helping you build and scale the Data Intelligence Platform.
***Opinions are my own***

View solution in original post

3 REPLIES 3

-werners-
Esteemed Contributor III

The notification settings are determined either by the UI or by DAB (formerly known as databricks asset bundles).
In either case they represent a fixed value and not a relative one (like 2 times the time of the previous run).
DAB is not code but yml config. But as said: a fixed value, not a formula.
Basically you either use the UI or DAB, because if you use both, the one will overwrite the other.

That being said: I would use dab. it is not real code but with yml quite a lot is possible.  But only fixed values though for this case.

Ashwin_DSA
Databricks Employee
Databricks Employee

Hi @rwalrondNHS,

You can set these thresholds and notifications programmatically. They’re part of the normal Jobs definition, not a UI‑only feature. I've just tested this for a sample job and it works perfectly.

Under the hood, the run longer than X --> send email UI maps to the below

  • health.rules with metric = RUN_DURATION_SECONDS, op = GREATER_THAN, value = <seconds>
  • email_notifications.on_duration_warning_threshold_exceeded = [ "you@example.com", ... ]

For example (Jobs API 2.1/2.2): This is the output I had from my sample job notification setting

{
  "health": {
    "rules": [
      {
        "metric": "RUN_DURATION_SECONDS",
        "op": "GREATER_THAN",
        "value": 60
      }
    ]
  },
  "email_notifications": {
    "on_duration_warning_threshold_exceeded": [
      "ashXX.XXX@XXX.com"
    ]
  }
}

If your deployment pipeline uses jobs/create or jobs/reset and doesn’t include these fields in the JSON/YAML it sends, those UI‑configured values get overwritten by whatever is in code (which in that case is "nothing"). That’s not a limitation of the feature, it’s just “"nfra as code" doing what it’s supposed to do: the code is treated as the source of truth.

So..it’s not true that you can’t set them via code. You absolutely can (and should, if you have weekly deploys). However, manual UI tweaks will be wiped if your job‑as‑code definition omits them on each deploy.

The UI is still useful for interactive editing and discovery, but in a CI/CD setup you’ll want to copy those settings into your job JSON/Terraform/Bundles config so they persist across rebuilds.

Hope this helps.

If this answer resolves your question, could you mark it as “Accept as Solution”? That helps other users quickly find the correct fix.

Regards,
Ashwin | Delivery Solution Architect @ Databricks
Helping you build and scale the Data Intelligence Platform.
***Opinions are my own***

It absolutely does help, it is exactly what I was asking Copilot can i do this in Databricks. So i'm glad i asked here as well 🙂  Many thanks.