메트릭 속성
메트릭 속성 (Metric properties)
메트릭은 Semantic Layer를 통해 질의할 수 있는 측정 가능한 수량을 정의해요. dbt 버전에 따라 모델(최신 YAML 스펙)이나 독립형 레거시 YAML 스펙에 정의해요. 이 페이지에서는 최신 YAML 스펙의 메트릭 속성을 다뤄요.
출처: 문서
본문
메트릭은 Semantic Layer를 통해 질의할 수 있는 측정 가능한 수량을 정의해요. dbt 버전에 따라 다른 곳에 정의해요:
- 모델에서 (최신 YAML 스펙): 최상위 메트릭.
semantic_model:과columns:와 함께 semantic modeling이 활성화된 모델에 목록으로 정의해요. dbt 플랫폼 v1 Latest release track과 dbt v2에서 사용 가능해요. - 독립형 레거시 YAML 스펙: Creating metrics 문서를 참고하세요.
가용성 (Availability) — 최신 YAML 스펙은 다음 환경에서 지원돼요:
- dbt 플랫폼 (v1 Latest release track)
- dbt v2
- dbt v1.12
자세한 내용은 Migrate to the latest YAML spec 문서를 참고하세요.
(dbt v1.12 이상) 최신 스펙 (모델 YAML)
최신 YAML 스펙에서는 semantic modeling이 활성화된 모델에 메트릭을 정의할 수 있어요. semantic_model과 columns와 함께 최상위 metrics 리스트를 추가해요 (메트릭은 semantic_model 아래에 중첩되지 않아요). 유형별 설정은 각 메트릭의 최상위 키예요.
사용 가능한 메트릭 속성 (최신 스펙)
| Property | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Unique metric name. Use lowercase letters, numbers, and underscores. |
| type | string | Yes | One of: simple, cumulative, ratio, derived, conversion. |
| description | string | No | Documentation for the metric. |
| label | string | No | Display name in downstream tools. |
| filter | string | No | MetricFlow filter expression (dimensions, entities, or other metrics). |
| config | object | No | Supports meta, group, tags, enabled. |
메트릭 유형별 속성 (최신 스펙)
| Metric type | Key properties |
|---|---|
| All | name, type, description, label, hidden, filter, config |
| Simple | agg, expr, time_granularity, agg_time_dimension, join_to_timespine, fill_nulls_with; optionally non_additive_dimension |
| Derived | expr, input_metrics (each with optional alias, filter, offset_window) |
| Ratio | numerator, denominator (each a metric name or a dict with name, filter, alias) |
| Conversion | entity, calculation, base_metric, conversion_metric, window; optional constant_properties |
| Cumulative | input_metric, window, grain_to_date, period_agg |
교차 모델 메트릭 (Cross-model metrics): 모델의 metrics: 리스트 아래 메트릭은 해당 semantic model만 참조할 수 있어요. 다른 semantic model에 의존하는 메트릭(예: 교차 모델 누적, 비율, 파생, 또는 전환)은 최상위 metrics: 블록(models: 밖)에 있어요. 이는 같은 YAML 파일이나 별도 파일에 있을 수 있어요.
참고: 레거시 스펙에서는 모든 메트릭이 독립형 YAML로 정의됐고, 모델 레벨
metrics:리스트는 없었어요.
최신 스펙은 Semantic models 문서를, 메트릭 유형·type_params·더 많은 예시는 Creating metrics 문서를 참고하세요.
더 알아보기 (Learn more)
- Creating metrics — 메트릭 정의하기
- Semantic models — 시맨틱 모델 속성
- Migrate to the latest YAML spec — 최신 YAML 스펙 마이그레이션