Back to Docs
Documentation

dbt Integration

Run all 299 MetricRegistry metrics directly in your data warehouse using the official dbt package.

Step 1

Install the package

Add the MetricRegistry package to your packages.yml and run dbt deps.

packages.yml
packages:
  - package: metricregistry/metricregistry_uk
    version: ">=0.1.0"
terminal
dbt deps
Step 2

Configure dataset mappings

Map each of the 18 registry datasets to your warehouse tables or dbt models using the metricregistry_datasets variable in dbt_project.yml.

dbt_project.yml
vars:
  metricregistry_datasets:
    capital:      "{{ ref('stg_capital') }}"
    exposures:    "{{ ref('stg_exposures') }}"
    credit:       "{{ source('banking', 'credit_data') }}"
    liquidity:    "{{ ref('stg_liquidity') }}"
    # ... map each dataset to your warehouse table

The 18 available datasets are:

bufferscapacitycapitalclimate_riskcreditemissionsexposuresfinancegovernanceliquidityplpopulationqualityregulatoryrwa_componentssocialwaiting_timesworkforce
Step 3

Run metrics

Each metric materializes as a view in your warehouse. Use standard dbt selectors to run all metrics or a targeted subset.

terminal
# Run all 299 metrics
dbt run --select metricregistry_uk

# Run only banking metrics
dbt run --select metricregistry_uk.banking

# Run a specific metric
dbt run --select metricregistry_uk.banking.capital.cet1_ratio
Step 4

MetricFlow export

Fetch dbt 1.6+ compatible MetricFlow YAML for any metric via the REST API. The response includes semantic_models and metrics blocks ready to drop into your dbt project.

terminal
curl https://api.metricregistry.co.uk/metrics/uk.banking.capital.cet1_ratio/export/metricflow \
  -H "Authorization: Bearer mrk_..."
Reference

How it works

The package uses a small set of macros to translate registry metric definitions into runnable SQL at compile time:

  • The mr_dataset() macro resolves dataset names to your configured table references from metricregistry_datasets.
  • Template variables in SQL (${column_name}) become actual column references resolved at compile time.
  • Each metric materializes as a view by default. Override with standard dbt config to use table or incremental.
  • Models are tagged with metricregistry, the industry, and the category for easy selection and documentation.

Next Steps