Skip to main content

A CLI tool to monitor individual dbt Cloud run jobs and receive OS notifications when they complete.

Project description

dbt-heartbeat

A CLI tool to monitor individual dbt Cloud run jobs and receive OS/Slack notifications when they complete.

Why This Exists

When working with large dbt projects that utilize a merge queue, developers often need to wait for long-running CI jobs to complete after syncing their branches with main before pushing changes. This tool solves two key problems:

  1. Manual Monitoring: Instead of repeatedly checking job status or working on other things and forgetting about your dbt job and holding up the merge queue, automatically get notified when your specific run job completes.
  2. Notification Control: AFAIK, dbt Cloud does not have notifications for job-specific runs. You can get notifications for all jobs of a specific environment/deployment, but not for specific runs within those environment/deployment jobs (i.e your own CI jobs in a staging environment).

All you need is a dbt Cloud developer PAT, dbt Cloud account ID, and a specific job run ID, and you'll be able to watch the status of the job run in your terminal and get notified when the job finishes.

Features

  • Poll dbt Cloud job runs and monitor their status
  • Terminal output with color-coded status updates
  • Can control the log level of the CLI output
  • Detailed job run status information once complete in the CLI + System/Slack notifications

Prerequisites

  • Python 3.8 or higher
  • dbt Cloud account with API access (via the dbt developer PAT)
  • A Python package manager such as:
    • uv>=0.6.11
    • pip>=25.1.1

NOTE: While uv is the recommended method for installing dbt-heartbeat, you can also install it using pip install. However, when installing with pip, you are responsible for managing your Python virtual environment and ensuring that the directory containing the executable is included in your system's PATH. In contrast, when using uv (particularly as described in the For General Use section below) no additional environment configuration is required, and the executable is automatically made available in your PATH for immediate use.

Installation - For General Use

  1. Add dbt environment variables to your shell configuration file (macOS defaults to ~/.zshrc)
    • Refer to the guide below for global export of environment variables for all terminal sessions
    • Other options are noted as well for non-global export of environment variables
  2. Install uv
    • Check the installation with uv --version
  3. Global installation:
    • Run uv tools install dbt-heartbeat
    • This will make dbt-heartbeat globally available on all terminal sessions
  4. Check the installation with dh --version
  5. Poll a job run!
    • dh <job_run_id>

Upgrading:

uv tool upgrade dbt-heartbeat

Configuration Guide for Environment Variables

The following environment variables are required and must be properly set:

  • DBT_CLOUD_API_KEY: Your dbt Cloud API key (must be non-empty)
  • DBT_CLOUD_ACCOUNT_ID: Your dbt Cloud account ID (must be non-empty)

The tool will validate these variables before starting and will notify you if any are missing or invalid.

Setting up Slack Notifications

To receive Slack notifications, you'll need to create your own Slack App and configure an Incoming Webhook URL. Here's the process:

  1. Go to api.slack.com/apps
  2. Click "Create New App"
  3. Choose "From scratch"
  4. Name the app (e.g., "dbt-heartbeat") and select the workspace
  5. Under "Features" → "Incoming Webhooks":
    • Turn on "Activate Incoming Webhooks"
    • Click "Add New Webhook to Workspace"
    • Choose a specific channel (or a DM with yourslef) where notifications should appear
    • Copy the Webhook URL provided
  6. Set up a SLACK_WEBHOOK_URL environment variable in your terminal session or shell configuration file:
    SLACK_WEBHOOK_URL="https://hooks.slack.com/services/YOUR/WEBHOOK/URL"
    

Once configured, you can use the --slack flag when running dh to send notifications to your specified Slack channel and/or DMs.

For global export

If you want to persist the environment variables in all terminal sessions without having to utilize a .env file or manually exporting the variables in your terminal session, you can add the export commands to your shell configuration file. (persisted)

# in shell configuration file (i.e `~/.zshrc` or `~/.bashrc`)
export DBT_CLOUD_API_KEY=your_dbt_cloud_api_key
export DBT_CLOUD_ACCOUNT_ID=your_dbt_cloud_account_id

For exporting manually in the terminal

Or export environment variables directly in your terminal session:

  • Exporting is scoped to the specific terminal session you are in (ephemeral)
# run these in the terminal
export DBT_CLOUD_API_KEY=your_dbt_cloud_api_key
export DBT_CLOUD_ACCOUNT_ID=your_dbt_cloud_account_id

Usage

For help:

dh --help

Poll a dbt Cloud run job:

dh <job_run_id> [--log-level LEVEL] [--poll-interval SECONDS]

Note: You can find the <job_run_id> in the dbt Cloud UI:

  • In the job run details page, look for Run #<job_run_id> in the header of each run
  • Or from the URL when viewing a job run: https://cloud.getdbt.com/deploy/<account_id>/projects/<project_id>/runs/<job_run_id>

Arguments

  • job_run_id: The ID of the dbt Cloud job run to monitor
  • --log-level: Set the logging level (default: INFO)
    • Choices: DEBUG, INFO, WARNING, ERROR, CRITICAL
  • --poll-interval: Time in seconds between polls (default: 30)
  • --slack: Send notifications to Slack (requires SLACK_WEBHOOK_URL environment variable)

Example

# Poll run job with default settings (system OS notifications)
dh 123456

# Poll run job with default settings and send message to slack
dh 123456 --slack

# Poll run job with debug logging and 15-second interval
dh 123456 --log-level DEBUG --poll-interval 15

Terminal Output

Screenshot 2025-05-15 at 7 47 02 AM

macOS Notification

Screenshot 2025-05-18 at 7 54 19 PM

Future Work & Limitations

The dbt CLoud API has a runs endpoint that's supposed to have a run_steps key within the data JSON object.

  • This would allow for dynamic output of which dbt command is currently running
  • Unfortunately, with dbt Cloud API v2, that endpoint has been unstable and is no longer populated leading to missing functionality for an enhanced CLI status output

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dbt_heartbeat-0.2.2.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dbt_heartbeat-0.2.2-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file dbt_heartbeat-0.2.2.tar.gz.

File metadata

  • Download URL: dbt_heartbeat-0.2.2.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.6

File hashes

Hashes for dbt_heartbeat-0.2.2.tar.gz
Algorithm Hash digest
SHA256 a45847c7eb81de9dba5577bc470e92bd2a869654b6925eb8294cfc408850094e
MD5 2d4f62d591ab36fb2d7a76c7b0b5345d
BLAKE2b-256 b438aec1b4ef7e21988e6cdbd8d78515141a11487b60f1ab4062eafe98f94041

See more details on using hashes here.

File details

Details for the file dbt_heartbeat-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for dbt_heartbeat-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2afada40f0c117c84f807ba95737835a512858ee012391b452814cee352e8ad7
MD5 370adb4f6479060714bfe96c4649e941
BLAKE2b-256 45fa29aef7289994fb49428e08b058c0fa6023ac61c3e261d1a5d7c4b4dc051d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page