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.7.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.7-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for dbt_webhook-0.3.7.tar.gz
Algorithm Hash digest
SHA256 f1f80aaba3ffee200c4a83ebd3923bf05768b76041274a8d1b95208ba0139c95
MD5 c5b0605c2ace09d4e7771274dc550207
BLAKE2b-256 e16de29bd1b1c80c972f0edf57e7f74b424faeb6aeeec27e56ef994682ac8e02

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dbt_webhook-0.3.7-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.11

File hashes

Hashes for dbt_webhook-0.3.7-py3-none-any.whl
Algorithm Hash digest
SHA256 26928bf641625181e333af1b417e939288b9e81686b5fcd218a717e8d578a0be
MD5 9cb8346a2a3fafd4bbcf7ea89e913a00
BLAKE2b-256 2b82be9ef5515746e35c96dcd5782d58055bb63b2aebaf0f3d3fc118776e4824

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