Skip to content

DBT: Alerts Dbt Models

DBT model name: alerts_dbt_models

Explore dependencies/lineage: link


Description

A view that is used by the Elementary CLI to generate models alerts, including all the fields the alert will include such as owner, tags, error message, etc. It joins data about models and snapshots run results, and filters alerts according to configuration.


Details

Column Type Description

No data tests defined 🧐

Not referenced by any model or exposure.

Models

Macros

  • edr_cast_as_timestamp
  • render_bool_config_var
  • get_config_var

No called script or script source not found.

{{ config(materialized="view", bind=False) }}

with
    error_models as (

        select
            model_execution_id,
            unique_id,
            invocation_id,
            name,
            generated_at,
            status,
            full_refresh,
            message,
            execution_time,
            execute_started_at,
            execute_completed_at,
            compile_started_at,
            compile_completed_at,
            compiled_code,
            database_name,
            schema_name,
            materialization,
            tags,
            package_name,
            path,
            original_path,
            owner,
            alias
        from {{ ref("model_run_results") }}

        union all

        select
            model_execution_id,
            unique_id,
            invocation_id,
            name,
            generated_at,
            status,
            full_refresh,
            message,
            execution_time,
            execute_started_at,
            execute_completed_at,
            compile_started_at,
            compile_completed_at,
            compiled_code,
            database_name,
            schema_name,
            materialization,
            tags,
            package_name,
            path,
            original_path,
            owner,
            alias
        from {{ ref("snapshot_run_results") }}
    )

select
    model_execution_id as alert_id,
    unique_id,
    {{ elementary.edr_cast_as_timestamp("generated_at") }} as detected_at,
    database_name,
    materialization,
    path,
    original_path,
    schema_name,
    message,
    owner as owners,
    tags,
    alias,
    status,
    full_refresh
from error_models
where
    {{ elementary.render_bool_config_var("disable_model_alerts", negate=true) }}
    and lower(status) != 'success'
    {%- if elementary.get_config_var("disable_skipped_model_alerts") -%}
        and lower(status) != 'skipped'
    {%- endif -%}