Monitor Databricks Jobs

Learn how to monitor Databricks jobs and view run history to track performance, debug failures, and optimize workflows in this hands-on tutorial.

Focus: monitor jobs and view run history

Sponsored

You've built and scheduled a Databricks job. It runs, it fails, it succeeds — but if you can't see why it behaved the way it did, you're flying blind. Without a clear view of run history, every failure is a mystery, every slow stage is a guess, and every retry is a gamble. This lesson shows you how to monitor jobs and view run history so you can track performance, debug failures with confidence, and keep your workflows healthy.

The problem this lesson solves

When a scheduled Databricks job fails at 2 AM, you need answers fast: Did it fail due to a code error, a cluster issue, or a data quality problem? How long did the last successful run take? Was that performance trend normal or a sign of trouble? If you rely on manual checks and scattered logs, you'll waste hours and risk downstream outages.

Monitoring jobs and viewing run history is your window into every execution: start and end times, status, cluster details, Spark UI, and logs. This lesson gives you the skills to observe your jobs systematically, so you can spot issues before they escalate and optimize confidently.

Core concept / mental model

Think of Databricks jobs as recipes and runs as each time you cook that recipe. The run history is your kitchen notebook — every attempt, success or failure, with timestamps, ingredients (cluster config), and notes (logs). Just as a chef reviews past attempts to perfect a dish, you review run history to perfect your data pipelines.

Key terms:

  • Job: A definition of work — tasks, schedule, cluster config, and notifications.
  • Run: A single execution of a job. A job can have many runs over time.
  • Run history: The chronological list of all runs for a job, with statuses and metadata.
  • Run ID: A unique identifier for each run, crucial for debugging and referencing in logs.

Pro tip: Always note the run ID when debugging. It's your main handle for correlating logs, metrics, and API calls.

How it works step by step

The Databricks UI and API track every run automatically. Here's the flow:

  1. Trigger: A run starts due to a schedule, manual trigger, or API call.
  2. Execution: The job's tasks run on a cluster. The platform records status changes (Pending, Running, Succeeded, Failed, Canceled).
  3. Logging: Each run's stdout/stderr and system logs are stored and linked to the run.
  4. Observation: You access run history via the UI (Jobs tab → job → Runs) or via API (runs/list).
  5. Drill-down: For a specific run, you can open the Spark UI, view metrics, and inspect logs to diagnose.

This loop — trigger, execute, log, observe — is continuous, and monitoring is your active role in it. You're not just watching; you're gathering intelligence for decisions: Do I need to scale the cluster? Is the job schema drift-prone? Should I set a retry policy?

Hands-on walkthrough

Monitor jobs in the Databricks UI

Navigate to the Jobs tab, click your job name, and you'll see a Runs list. Each row shows status, start/end times, duration, and a link to the run details.

Illustration: Job runs list showing statuses

Click a run to see:

  • Run status: Succeeded, Failed, Canceled, or Pending.
  • Timing: Start, end, and duration.
  • Cluster: Which cluster or cluster policy was used.
  • Spark UI: For in-depth stage and task metrics.
  • Logs: Stdout, stderr, and system logs.

Use the Databricks CLI to list runs

The CLI gives you scriptable access. For example:

# Set your Databricks host and token
export DATABRICKS_HOST=https://your-workspace.cloud.databricks.com
export DATABRICKS_TOKEN=your-personal-access-token

# List the runs for a specific job (replace JOB_ID)
databricks runs list --job-id 1234 --limit 10

Example output:

Run ID   Status      Start Time               Duration
5678     SUCCESS     2024-05-01 10:00:00     15m 30s
5679     FAILED      2024-05-01 11:00:00     2m 10s
5680     PENDING     2024-05-01 12:00:00     -

Programmatic monitoring with the API

For automated monitoring, use the Databricks REST API from Python:

import requests
import os

host = os.environ["DATABRICKS_HOST"]
token = os.environ["DATABRICKS_TOKEN"]
job_id = 1234

response = requests.get(
    f"{host}/api/2.1/jobs/runs/list",
    headers={"Authorization": f"Bearer {token}"},
    params={"job_id": job_id, "limit": 5},
)
response.raise_for_status()

for run in response.json().get("runs", []):
    run_id = run["run_id"]
    status = run["state"]["life_cycle_state"]
    result = run["state"]["result_state"] if "result_state" in run["state"] else "--"
    print(f"Run ID {run_id}: {status}, result {result}")

Output (example):

Run ID 5678: TERMINATED, result SUCCESS
Run ID 5679: TERMINATED, result FAILED
Run ID 5680: PENDING, result --

This lets you alert on failures, track SLA times, and build dashboards.

Compare options / when to choose what

Here's a comparison of the three primary ways to monitor jobs and view run history:

Method Best for Pros Cons
Databricks UI Ad-hoc inspection, quick debugging Visual, no setup, built-in Spark UI Not scalable for many jobs, manual
CLI Scripting and automation on demand Flexible, easy in shell scripts Requires auth setup
REST API Programmatic monitoring, integration Full control, can build custom tools More code, need to handle pagination

When to choose what: Use the UI for quick checks and root-cause analysis. Use the CLI for simple one-off queries or cron jobs. Choose the API when you need custom dashboards, alerting, or integration with existing systems.

Troubleshooting & edge cases

  • Job shows 'Skipped': This usually means the run was triggered but an upstream task failed. Check the parent run's status and logs.
  • Run stuck in 'Pending': The cluster may be starting or resources are unavailable. Check cluster status and retry the run.
  • Logs not visible: Ensure you have permission to view job logs. Also check if the cluster was terminated; logs may be lost.
  • API returns empty list: Confirm you're using the correct API version (e.g., 2.1) and that the job ID is valid. Check your token has jobs:read scope.
  • Timeouts in long-running runs: Set timeouts at the task level to avoid infinite runs. Use the 'Timeout' field in job settings.

Pro tip: Set up email or Slack notifications in the job properties so you get immediate alerts on failure. You can monitor proactively, not reactively.

What you learned & what's next

You can now confidently monitor jobs and view run history in Databricks. You understand the UI, CLI, and API approaches, how to drill into run details, and how to troubleshoot common issues. You've learned to check status, timing, logs, and Spark UI — all essential for maintaining reliable data pipelines.

Next lesson: In the upcoming module, you'll learn how to automate job retries and alerts using job properties and notification systems. This builds on your monitoring skills to create self-healing workflows.

Keep your run history knowledge sharp — it'll serve you well in every future Databricks project.

Practice recap

Practice by creating a simple Databricks job (or reusing one from a previous lesson), manually triggering a run, and then monitoring it via the UI and the CLI. Deliberately introduce a small error in the notebook, rerun, and practice finding the failure in the logs. This hands-on cycle will solidify your monitoring workflow.

Common mistakes

  • Ignoring run logs: Always check stdout/stderr and system logs when a run fails — the run ID is your key to these logs.
  • Using the UI for bulk monitoring: Manually checking the UI isn't practical for many jobs; switch to the CLI or API for scale.
  • Forgetting to set notifications: Without notification settings, you'll discover failures too late — configure email or Slack alerts.
  • Misreading skipped tasks: A 'Skipped' status often means a dependency has failed; trace back to the parent run.
  • Relying on default timeout: Long-running jobs can fail silently due to no timeout — set task-specific timeouts.

Variations

  1. You can monitor runs using Databricks SQL queries against the system tables, such as system.jobs.run_history, for advanced analytics.
  2. For real-time visibility, integrate Databricks with external monitoring tools like Grafana via the REST API.
  3. Use the Databricks Terraform provider to manage job definitions and monitor run statuses as part of your Infrastructure as Code.

Real-world use cases

  • A data engineer monitors nightly ETL job runs to ensure the dashboard data is fresh, alerting on any failures.
  • A DevOps team uses the REST API to track job run times and set up a custom dashboard to identify slow-running pipelines.
  • A data analyst investigates a failed report generation by viewing the run history and logs to pinpoint a schema change.

Key takeaways

  • Run history is the central record for every job execution — use it to debug and optimize.
  • The Databricks UI provides deep run details, including the Spark UI, for root-cause analysis.
  • The CLI and REST API enable programmatic monitoring, which scales to many jobs.
  • Always monitor key metrics: status, timing, cluster, and logs.
  • Set up notifications to catch failures early.
  • Use the run ID as the anchor for any investigation.

Sponsored

Sponsored

Discussion

Questions, corrections, and tips help everyone reading this page.

0 comments

Add a comment

Shown publicly with your comment.

Be constructive · max 4,000 characters

No comments yet — start the thread.

Related tutorials, quizzes, and articles for this topic.