Skip to main content

Using Transform with dbt metrics

Transform now integrates with dbt metrics! Transform will parse your dbt project to generate and translate the result into a model. You can then query your metrics in any supported integaration, and in the Transforn UI.

Setting up the integration with Transform

  1. Configure metrics in your dbt project. For example, we have the metric salesforce_opportunties.
- name: salesforce_opportunities
label: Opportunities
model: ref('opportunity_base')
description: "Count of opportunities"
calculation_method: count_distinct
expression: id
timestamp: created_date
time_grains: [day, week, month]
- stage_name
meta: {team: Sales}
  1. Install transform-tools in your dbt project with pip install "transform-tools[your-dbt-adapter]"
  2. Set the usual required transform-tools environment variables + IS_DBT_PROJECT="true". An example pipleine for Github would be:
name: Validate Configs
on: pull_request
runs-on: ubuntu-latest
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
python-version: '3.8.5' # arbitrarily chosen
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install "transform_tools[your-dbt-adapter]"
#supported adapters dbt-snowfake, dbt-redshift, dbt-postgres, dbt-bigquery
- name: Run validate script
run: python -m transform_tools.validate validate
TRANSFORM_CONFIG_DIR: ${{ secrets.TRANSFORM_CONFIG_DIR }} # TRANSFORM_CONFIG_DIR may be added to repo secrets settings (repo-root is used otherwise)
REPO: ${{ github.repository }}
TRANSFORM_API_KEY: ${{ secrets.TRANSFORM_API_KEY }} # TRANSFORM_API_KEY must be in repo secrets settings

  1. Your metrics should now be available! You can confirm by running a test query like the one below, or by viewing the metric in the Transform UI
mql query --metrics salesforce_opportunities --dimensions metric_time