(Last updated on )
dbt のモデルを参照しているダッシュボードの定期更新
dbt のモデルを参照しているダッシュボードの定期更新
下記の流れで、定期更新している。
dbt Exposuresでダッシュボードを管理YAML Selectorsで更新するモデルを管理GitHub Actionsでモデルの定期更新
dbt Exposures でダッシュボードを管理
dbt Exposures の設定
models/exposures/dashboard/exp_*.yml
version: 2
exposures:
- name: exp_account_count_transition
label: 会員数推移
description: >
{{ doc("exp_account_count_transition_description") }}
type: dashboard
url: https://docs.google.com/spreadsheets/d/xxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxx/edit#gid=xxxxxxxxx
maturity: low
tags:
- account
- transition
- kpi
- monitoring_dashboard
- monitoring_dashboard_at_0800
owner:
name: requesting_department
email: [email protected]
depends_on:
- ref('rpt_account_hogehoge')
- ref('rpt_account_fugafuga')
models/exposures/dashboard/_dashboard.yml
{% docs exp_account_count_transition_description %}
## 用途
<!-- 略 -->
## 運用方法
<!-- 略 -->
## 参考資料
<!-- 略 -->
## メモ
<!-- 略 -->
{% enddocs %}
プロパティ
dbt Exposures で設定できるプロパティ。
name
ダッシュボードの名前(英語)。
label
ダッシュボードの名前(日本語)。
description
ダッシュボードの説明。
type
タイプ。
ダッシュボードなので、dashboard を設定。
url
URL。
ダッシュボードの URL を設定。
maturity
成熟・完成度。
tags
タグ。
owner
ダッシュボードの利用者の名前(name)とメールアドレス(email)。
depends_on
ダッシュボードで参照しているモデル。
YAML Selectors で更新するモデルを管理
モニタリングしているダッシュボードに、monitoring のタグを付与。
08:00 に更新したいダッシュボードには、monitoring_model_at_0800 のタグを付与。
設定
selectors.yml
selectors:
- name: run_and_seed_at_0800
description: 08:00 の定期更新対象の seed, model
definition:
union:
- '+tag:monitoring_model_at_0800'
- '+tag:monitoring_dashboard_at_0800'
- name: test_at_0800
description: 08:00 の定期更新対象の test
definition:
union:
- 'tag:monitoring_model_at_0800'
- '1+tag:monitoring_dashboard_at_0800'
- exclude:
- 'tag:big_model'
run_and_seed_at_0800
08:00 の定期更新対象の seed, model
+tag:monitoring_model_at_0800monitoring_model_at_0800のタグを付与しているモデルmonitoring_model_at_0800のタグを付与しているモデルが参照しているモデル
+tag:monitoring_dashboard_at_0800monitoring_dashboard_at_0800のタグを付与しているdbt Exposuresがdepends_onで指定しているモデルmonitoring_dashboard_at_0800のタグを付与しているdbt Exposuresがdepends_onで指定しているモデルが参照しているモデル
test_at_0800
08:00 の定期更新対象の test
tag:monitoring_model_at_0800monitoring_model_at_0800のタグを付与しているモデル
1+tag:monitoring_dashboard_at_0800:monitoring_dashboard_at_0800のタグを付与しているdbt Exposuresがdepends_onで指定しているモデル
tag:big_modelbig_modelのタグを付与しているモデルはコストが嵩むため除外
GitHub Actions でモデルの定期更新
GitHub Actions で下記を実行している。
モデルの更新
$ dbt run --selector run_and_seed_at_0800
テスト
$ dbt run --selector test_at_0800
