Skip to main content

A DBT plugin that allows defining HTTP hooks for DBT commands and/or models, triggering them at execution start/end, and injecting the returned data into the model's metadata.

Project description

dbt-webhook

PyPI version

A dbt plugin that allows defining HTTP hooks for DBT commands and/or models, triggering them at execution start/end, and injecting the returned data into the model's metadata.

How It Works

Below is a diagram describing how the plugin works and the different types of hooks:

dbt-webhook design


Getting Started

dbt-webhook is designed to work with dbt-core, allowing data infrastructure teams to extend functionality via additional Python packages.

To start using dbt-webhook, follow these three steps:

1. Install the dbt-webhook Package

Install dbt-webhook in your local development environment and in the environment running scheduled jobs (e.g., Airflow):

pip install dbt-webhook

2. Create a dbt-webhook Configuration File

Create in work dir file dbt_webhook.yml and configure hooks you want to run.

Example Configuration

command_start_hook:
  command_types:
    - "compile"
  webhook_url: "https;//domain.example.com/dbt/command/start"
  webhok_method: "POST"
  headers:
    Content-Type: "application/json"

command_end_hook:
    # Same schema as above

model_start_hook:
    # Same schema as above

model_end_hook:
    # Same schema as above

Configuration Notes:

  • By default, the plugin will search for dbt_webhook.yml in the working directory:
    • In VSCode (when using the dbt Power User extension), this is the workspace directory.
    • In Airflow, the working directory may differ (e.g., the project directory).
    • If the local and scheduled work directories differ, you can create a symlink to avoid duplicating the configuration file.
  • If the HTTP endpoint requires authentication, pass secrets via environment variables:
  headers:
    Authorization: "bearer {DBT_WEBHOOK_AUTH_TOKEN}"
    Content-Type: "application/json"
  env_vars:
    - "DBT_WEBHOOK_AUTH_TOKEN"

3. Create HTTP Endpoints

The format of request and response payloads is defined in dbt_webhook/webhook_model.py using Pydantic models.

Command Hooks Request/Response Schema

{
    "command_type": "run",
    "invocation_id": "<UUID generated on dbt command start>",
    "run_started_at": "<timestamp>",
    "run_finished_at": "<timestamp>",
    "success": True | False | None
    "nodes": {
        "model.project.my_first_dbt_model": {
            "unique_id": "model.project.my_first_dbt_model",
            "meta": {"field1": 'val1'},
            "node_started_at": "<timestamp>",
            "node_finished_at": "<timestamp>",
            "target_database": "<db | project>",
            "target_schema": "<dataset | schema>",
            "target_table_name": "my_first_dbt_model",
            "success": True | False | None,
        },
        "<some other model unique id>": {...},
        ...
    },
}

Node Hooks Request/Response Schema

For node hooks, the schema is similar, but instead of a nodes dictionary, there is a single node object:

{
    "command_type": "run",
    "invocation_id": "<UUID generated on dbt command start>",
    "run_started_at": "<timestamp>",
    "run_finished_at": "<timestamp>",
    "success": True | False | None
    "node": {
        "unique_id": "model.project.my_first_dbt_model",
        "meta": {"field1": 'val1'},
        "node_started_at": "<timestamp>",
        "node_finished_at": "<timestamp>",
        "target_database": "<db | project>",
        "target_schema": "<dataset | schema>",
        "target_table_name": "my_first_dbt_model",
        "success": True | False | None,
    },
}

Contributing

Contributions are welcome! Feel free to submit issues or open pull requests on GitHub.

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_webhook-0.3.6.tar.gz (12.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_webhook-0.3.6-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file dbt_webhook-0.3.6.tar.gz.

File metadata

  • Download URL: dbt_webhook-0.3.6.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for dbt_webhook-0.3.6.tar.gz
Algorithm Hash digest
SHA256 d362a13f38728f5972667f7e4de0047ff65efb8000f9f8ac4176128ec97523b5
MD5 2204dd46f3773d9c422b96ae75e9c889
BLAKE2b-256 75247553edb93b2a852216f8fd60fa5fc21e9bb0ae5bc2cf1b14acbecec1be90

See more details on using hashes here.

File details

Details for the file dbt_webhook-0.3.6-py3-none-any.whl.

File metadata

  • Download URL: dbt_webhook-0.3.6-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for dbt_webhook-0.3.6-py3-none-any.whl
Algorithm Hash digest
SHA256 1c4dc944a6b269b7caf610aa44698c3b775ebbb5bb6286db94b7be03e88f51e4
MD5 493ca5e94674ba1e03d29dcfee3b9a9e
BLAKE2b-256 fb6be27eaa796f51c78b3f18e8cf80eaf4bf29881b4a80fc810745bc5cac632c

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