-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Keep old alerts tables for backwards
- Loading branch information
1 parent
32e8aeb
commit 7d3deef
Showing
3 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
elementary/monitor/dbt_project/models/alerts/deprecated/alerts.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{{ | ||
config( | ||
materialized = 'incremental', | ||
unique_key = 'alert_id', | ||
merge_update_columns = ['alert_id'], | ||
on_schema_change = 'sync_all_columns', | ||
table_type=elementary.get_default_table_type(), | ||
incremental_strategy=elementary.get_default_incremental_strategy() | ||
) | ||
}} | ||
|
||
{% set anomaly_detection_relation = adapter.get_relation(this.database, this.schema, 'alerts_anomaly_detection') %} | ||
{# Backwards compatibility support for a renamed model. #} | ||
{% set data_monitoring_relation = adapter.get_relation(this.database, this.schema, 'alerts_data_monitoring') %} | ||
{% set schema_changes_relation = adapter.get_relation(this.database, this.schema, 'alerts_schema_changes') %} | ||
|
||
with failed_tests as ( | ||
select * from {{ ref('elementary', 'alerts_dbt_tests') }} | ||
|
||
{% if schema_changes_relation %} | ||
union all | ||
select * from {{ schema_changes_relation }} | ||
{% endif %} | ||
|
||
{% if anomaly_detection_relation %} | ||
union all | ||
select * from {{ anomaly_detection_relation }} | ||
{% elif data_monitoring_relation %} | ||
union all | ||
select * from {{ data_monitoring_relation }} | ||
{% endif %} | ||
) | ||
|
||
select | ||
{{ dbt_utils.star(from=ref('elementary', 'alerts_dbt_tests'), except=["detected_at"]) }}, | ||
{{ elementary_cli.get_alerts_model_detected_at_expr(this) }} as detected_at, | ||
false as alert_sent, {# backwards compatibility #} | ||
'pending' as suppression_status, | ||
{{ elementary.edr_cast_as_string('NULL') }} as sent_at | ||
from failed_tests | ||
|
||
{%- if is_incremental() %} | ||
{{ elementary_cli.get_new_alerts_where_clause(this) }} | ||
{%- endif %} |
26 changes: 26 additions & 0 deletions
26
elementary/monitor/dbt_project/models/alerts/deprecated/alerts_models.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{{ | ||
config( | ||
materialized = 'incremental', | ||
unique_key = 'alert_id', | ||
merge_update_columns = ['alert_id'], | ||
on_schema_change = 'sync_all_columns', | ||
table_type=elementary.get_default_table_type(), | ||
incremental_strategy=elementary.get_default_incremental_strategy() | ||
) | ||
}} | ||
|
||
{% set error_models_relation = adapter.get_relation(this.database, this.schema, 'alerts_dbt_models') %} | ||
{% if error_models_relation %} | ||
select | ||
{{ dbt_utils.star(from=error_models_relation, except=["detected_at"]) }}, | ||
{{ elementary_cli.get_alerts_model_detected_at_expr(this) }} as detected_at, | ||
false as alert_sent, {# backwards compatibility #} | ||
'pending' as suppression_status, | ||
{{ elementary.edr_cast_as_string('NULL') }} as sent_at | ||
from {{ error_models_relation }} | ||
{% if is_incremental() %} | ||
{{ elementary_cli.get_new_alerts_where_clause(this) }} | ||
{% endif %} | ||
{% else %} | ||
{{ elementary_cli.empty_alerts_models() }} | ||
{% endif %} |
26 changes: 26 additions & 0 deletions
26
elementary/monitor/dbt_project/models/alerts/deprecated/alerts_source_freshness.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{{ | ||
config( | ||
materialized = 'incremental', | ||
unique_key = 'alert_id', | ||
merge_update_columns = ['alert_id'], | ||
on_schema_change = 'sync_all_columns', | ||
table_type=elementary.get_default_table_type(), | ||
incremental_strategy=elementary.get_default_incremental_strategy() | ||
) | ||
}} | ||
|
||
{% set alerts_source_freshness_relation = adapter.get_relation(this.database, this.schema, 'alerts_dbt_source_freshness') %} | ||
{% if alerts_source_freshness_relation %} | ||
select | ||
{{ dbt_utils.star(from=alerts_source_freshness_relation, except=["detected_at"]) }}, | ||
{{ elementary_cli.get_alerts_model_detected_at_expr(this) }} as detected_at, | ||
false as alert_sent, {# backwards compatibility #} | ||
'pending' as suppression_status, | ||
{{ elementary.edr_cast_as_string('NULL') }} as sent_at | ||
from {{ alerts_source_freshness_relation }} | ||
{% if is_incremental() %} | ||
{{ elementary_cli.get_new_alerts_where_clause(this) }} | ||
{% endif %} | ||
{% else %} | ||
{{ elementary_cli.empty_alerts_source_freshness() }} | ||
{% endif %} |