Skip to content

On a schedule

Get a Slack alert when a job runs too long

Any run still going after two hours is flagged in Slack once, so stuck jobs don't burn compute all night.

Runs
On a schedule
Apps
Databricks
AI
Not needed
Access
read jobs

Send this to your assistant

Create a ClickRuntime automation: every 15 minutes, check active Databricks job runs and post to #data-eng in Slack if any have been running for more than 2 hours. Only alert once per run.

Paste it into your assistant. It tells you what it will send or change before it runs live.

First time? Adding ClickRuntime to your assistant takes about two minutes.

Why use it

Why teams use this automation

A Databricks job that should take twenty minutes and is still running after two hours is almost always in trouble. A skewed join is stuck on one partition, a cluster is waiting for resources, or a notebook is looping. Every extra hour burns compute and holds up whatever depends on the result.

On a schedule, this lists the active runs, works out how long each has been running, and sends a Slack message the first time a run passes two hours. The alert is sent once per run, so the channel does not fill with repeated warnings.

Platform teams and engineers who own critical pipelines use it to catch hangs before the cost and the delays pile up. Duration is worked out from the start time of each active run, so the alert measures what is happening now, and it is sent once per run so the channel stays readable.

What you get out of it

  • Stop hung jobs wasting compute

    A stuck job costs money by the hour. Hearing about it at the two-hour mark means you can cancel it before it burns an entire night of compute. A stuck job costs money by the hour, and hearing about it at two hours means you can cancel before a night of compute is wasted.

  • Protect downstream deadlines

    Reports and models waiting on a slow job miss their deadlines. An early warning gives the owner time to rerun or notify stakeholders. Reports and models waiting on a slow job miss deadlines, and an early warning gives the owner time to rerun or tell stakeholders.

  • Alert once per run

    Because each run is reported a single time, you can trust the channel. A repeated warning every poll would soon be muted and ignored. Each run is reported a single time, so the channel stays trustworthy, and a repeated warning every poll would soon be muted.

  • Find jobs that are slowly degrading

    Jobs that regularly cross the threshold show growing data volumes or inefficient code. Those are the ones to optimise next. Jobs that regularly cross the threshold reveal growing data volumes or inefficient code, which are the ones to optimize next.

  • Give on-call engineers clear information

    The message names the run, so the person on call knows exactly what to investigate. They do not have to scan the jobs page for suspicious entries. The message names the run, so the on-call engineer knows exactly what to investigate and does not scan the jobs page.

How it works

What happens, step by step

  1. Every 15 minutes, ClickRuntime checks which Databricks jobs are currently running.

  2. It works out how long each one has been going.

  3. Any run that has passed two hours is posted to your Slack channel with its name, how long it has run and a link.

  4. Each run is flagged only once, however long it keeps going.

Before it runs live

  • Connect Databricks

What you get

RunsOn a schedule
Get a Slack alert when a job runs too longtoday, 9:00Succeeded
Slack · #data-engnightly_orders_etl has been running for 2.3h https://dbc-a1b2c3d4-e5f6.cloud.databricks.com/#job/123/run/789

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • Your own rules

    Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.

  • Any number of apps

    One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.

  • AI where it helps

    Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.

  • On a schedule or on each event

    Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.

Changes you can ask for

  • Act only on the items that match your own rules, and skip the rest
  • Add an AI step, for example to summarize, sort or draft a reply
  • Add another app, for example also send it to Slack
  • Combine it with other Databricks steps into one automation

Under the hood

The code that runs this automation

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
long_running_job_alert.pyexample
import time
from clickruntime import on_trigger, credentials, http, state, notify

HOST = "https://dbc-a1b2c3d4-e5f6.cloud.databricks.com"
MAX_HOURS = 2

@on_trigger
def run(event):
    data = http.get(f"{HOST}/api/2.1/jobs/runs/list",
                    headers={"Authorization": f"Bearer {credentials.secret('DATABRICKS_TOKEN')}"},
                    params={"active_only": "true", "limit": 25}).json()
    alerted = set(state.get("alerted") or [])
    active = data.get("runs", [])
    for r in active:
        hours = (time.time() * 1000 - r["start_time"]) / 3_600_000
        if hours > MAX_HOURS and r["run_id"] not in alerted:
            notify.slack(f"{r['run_name']} has been running for {hours:.1f}h\n{r['run_page_url']}",
                         channel="#data-eng")
            alerted.add(r["run_id"])
    state.set("alerted", [i for i in alerted if i in {r["run_id"] for r in active}])
    return {"active": len(active)}

FAQ

Common questions

Can I change the two hour limit?
Yes. Different jobs have different normal lengths, so you might choose 30 minutes for one and four hours for another. Your AI assistant can set limits per job and show the changes for approval. Limits can differ by job, such as 30 minutes for one and four hours for another, and your OK is required.
How often does it check for long runs?
On the polling schedule you set, typically every few minutes. The alert arrives shortly after a run crosses the threshold, with a delay of up to one polling interval. The check runs on the polling schedule you set, so an alert arrives within one interval after a run crosses its limit.
Does it cancel the run automatically?
No. It only sends a Slack alert. Cancelling a job is a decision for a person, and an automatic cancel step could be added only if you ask for it and approve the change. Only the Slack alert is sent, because cancelling a job is a decision for a person, and a cancel step would be a separate reviewed addition.
What permissions does it need?
read jobs. Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's AI allowance.
How many runs does it use?
One run each time it checks. Checks that find nothing new and stop right away aren't counted.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

Set up “Get a Slack alert when a job runs too long” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.