Comment on page
Metrics
Using dbt Metrics with PipeRider
From dbt 1.6, support for the dbt_metrics package was deprecated and replaced by the Semantic Layer. Likewise, from version 0.33.0 of PipeRider, support for the legacy metric config has also been discontinued. Metrics defined using the old configuration will now be automatically skipped by PipeRider.
- 1.Define semantic models and metrics in your dbt project
- 2.Validate metric configuration
- 3.Run PipeRider
For full details on how to define metrics, please refer to the official dbt documentation on the semantic model and creating metrics.
The following serves as a basic example on how to define a metric. Here, we define a metric revenue, which is the sum of the amount column with a status of completed.
models/marts/orders.yml
semantic_models:
- name: orders
defaults:
agg_time_dimension: order_date
model: ref('orders')
entities:
- name: order_id
type: primary
- name: customer
type: foreign
expr: customer_id
dimensions:
- name: order_date
expr: order_date
type: time
type_params:
time_granularity: day
- name: status
type: categorical
measures:
- name: revenue
description: "The total revenue of our jaffle business"
agg: sum
expr: amount
metrics:
- name: revenue
description: "The total revenue of our jaffle business"
type: simple
label: Revenue
type_params:
measure: revenue
filter: |
{{ Dimension('order_id__status') }} = 'completed'
$ dbt-parse
dbt has also released a powerful tool, MetricFlow CLI that, among other features, can also validate your metric configuration:
$ mf validate-configs
MetricFlow CLI can also query the metric to ensure it is functional:
$ mf query --metrics revenue --group-by metric_time__month
✔ Success 🦄 - query completed after 0.12 seconds
| metric_time__month | revenue |
|:---------------------|----------:|
| 2023-05-01 | 69.00 |
| 2023-06-01 | 420.00 |
| 2023-07-01 | 478.00 |
| 2023-08-01 | 136.00 |
Once your metrics are correctly configured, run PipeRider:
$ piperider run
View metrics in your PipeRider Report by selecting the
metrics
page form the project sidebar:
PipeRider can run daily, monthly, and yearly queries for your metrics. If the time_granularity is defined, the queries will adhere to these settings. For example, if the
time_granularity
is month
, then PipeRider only run the monthly and yearly queries.For each time grains, PipeRider only queries the last n periods
time_grain | metric query |
---|---|
day | daily result for last 30 days |
month | monthly result for last 12 months |
year | yearly result for last 10 years |
The behavior is identical to the following command in MetricFlow.
$ mf query --metrics revenue --group-by metric_time__day --start-time <30d ago>
$ mf query --metrics revenue --group-by metric_time__month --start-time <12m ago>
$ mf query --metrics revenue --group-by metric_time__year --start-time <10y ago>
- PipeRider no longer supports metric specification prior to dbt v1.6. dbt provides official documentation on how to migrate metrics configs to the new spec.
- PipeRider doesn't support metrics that use measures with
agg
, such assum_boolean
,median
, andpercentile
{{ Dimension('order_id__status') }} = 'completed'
is supported becauseorder_id
is type ofprimary
{{ Dimension('customer__type') }} = 'vip'
is not supported becausecustomer
is type offoreign
, and so requires additional join
When developing a new metric, it is time-consuming to run through all the piperider run to test the metric result. PipeRider support dbt node selection to run on single metric
$ piperider run -s 'metric:jaffle_shop.revenue'
With PipeRider's compare feature, you're also able to compare metrics between reports, which is particularly useful when analyzing the impact of data model or metric definition changes.

Metric comparison in a PipeRider Impact Report
Last modified 3mo ago