Configure anomaly detection

Configure anomaly detection

This section outlines the steps to enable anomaly detection for your assets. The setup involves configuring it once for your space and then enabling anomaly detection for individual assets.

Space setup

This section outlines the steps to configure the anomaly detection package for your space. This is a one-time operation. The package is a Y42-customized version of the Elementary Data package (opens in a new tab).

Add the dbt-data-reliability package

To incorporate anomaly detection into your project space, add the following code into your packages.yml file:

packages.yml

_10
packages:
_10
- git: https://github.com/goes-funky/dbt-data-reliability.git
_10
revision: 97ec44895f0926954fb7303929a95bea0105f0ae

To find the latest commit hash, navigate to the "Commits" section of the repository and use the "Copy" option.

You can find out more about installing and maintaining dbt packages here.

Configure dbt_project.yml

Add the following to the models section of your dbt_project.yml:

dbt_project.yml

_10
models:
_10
y42_project:
_10
staging:
_10
+materialized: view
_10
elementary:
_10
+schema: "elementary"

Commit changes

After updating packages.yml and dbt_project.yml, commit the changes.

Asset-level configuration

This section details how to enable anomaly detection for specific assets

Enabling anomaly detection for an asset

To update the .yml configuration of your source or model asset, modify the config and tests blocks as follows:

source_or_model.yml

_18
version: 2
_18
_18
sources:
_18
- name: < model name >
_18
# other properties
_18
tables:
_18
- name: orders
_18
config:
_18
# other properties
_18
elementary:
_18
timestamp_column: < timestamp column >
_18
tests:
_18
- elementary.all_columns_anomalies:
_18
column_anomalies: < specific monitors, all if null >
_18
where_expression: < sql expression >
_18
time_bucket: # Daily by default
_18
period: < time period >
_18
count: < number of periods >

Commit changes

After updating the .yml, commit the changes.

Building an asset

When running an asset, anomaly detection behaves like standard tests. Findings are available in "Build details -> Test" section for review. To view them, navigate to "Build history" and select a specific run.

Anomaly detection test success.

Anomaly detection test success.

Anomaly detection test failure.

Anomaly detection test failure.