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 Slack or OS notifications when they complete.
Why This Exists
Developers working with large dbt projects and merge queues often wait for long-running CI jobs. This tool solves two problems:
- 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.
- 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).
Prerequisites
- Python >= 3.8
uv(Python package manager)- dbt Cloud account with API access (via the dbt developer PAT)
- Environment variables:
DBT_CLOUD_ACCOUNT_IDDBT_CLOUD_API_KEYSLACK_WEBHOOK_URL- Only needed if posting notifications to Slack (need a valid Slack App with an authorized webhook URL)
- Default behavior of
dhis to post to OS notifications
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 no additional environment configuration is required, and the executable is automatically made available in your PATH for immediate use.
Installation
brew install uvuv tool install dbt-heartbeat- Add environment variables to your
.zshrcshell configuration file:# Paste in your .zshrc file (Mac: /Users/<user_name>/.zshrc) export DBT_CLOUD_ACCOUNT_ID=<dbt_cloud_account_id> export DBT_CLOUD_API_KEY=<dbt_cloud_pat> export SLACK_WEBHOOK_URL=<webhook_url>
- Run
dh <run_job_id> --slack
Version Upgrade:
# Check for latest version
dh --version
# Upgrade to the latest version
uv tool upgrade dbt-heartbeat
Usage
For help:
dh --help
Arguments
job_run_id: The ID of the dbt Cloud job run to monitor-
--slackor-s: Send notifications to Slack (requires SLACK_WEBHOOK_URL environment variable)
--poll-interval: Time in seconds between polls (default: 30)--log-level: Set the logging level (default: INFO)- Choices: DEBUG, INFO, WARNING, ERROR, CRITICAL
--version: Checks for the latest version and prints the current version
Example
# Poll run job with default settings and send notification to system OS
dh 123456
# Poll run job with default settings and send notification to Slack
dh 123456 --slack
# Poll run job with debug logging and 15-second interval and send notification to Slack
dh 123456 --s --log-level DEBUG --poll-interval 15
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>
Terminal Output
Slack App Notification
Note on Internal Slack App for Webhook URL Generation
- A single app can be shared within a workspace so that end users don't have to repeteadly create a Slack app from scratch just to generate their own unique webhook URL
- As an example, I created a
dbt-heartbeatSlack App in my company's workspace and authorized the incoming webhook URL to post messages to the Slack App's Direct Message- This app can be reused and shared with others to configure their own unique webhook URLs for posting messages from
dh
- This app can be reused and shared with others to configure their own unique webhook URLs for posting messages from
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dbt_heartbeat-0.2.3.tar.gz.
File metadata
- Download URL: dbt_heartbeat-0.2.3.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f64b8df0935c1515263261415878f28d6d105190fafc81fdc9e3b768d9e4978
|
|
| MD5 |
951c4333645c3c0500b057ed6a2e95d6
|
|
| BLAKE2b-256 |
089ff647b689cf1b411859b8b5710393bf413aa1fce6637741a0fce542a53345
|
File details
Details for the file dbt_heartbeat-0.2.3-py3-none-any.whl.
File metadata
- Download URL: dbt_heartbeat-0.2.3-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfa8970c6b29595c9af303e152f159c4885aeafef6d4d1cc31b3eb7a4517ab84
|
|
| MD5 |
5a260b46955203c73f5cbfcd87d3d4df
|
|
| BLAKE2b-256 |
f6ad1d99eb5f1e9442e19a83c6b6983c1a5b8d8901e4db8190d7beaf381a897a
|