Noya Offer
03/16/2025, 10:49 AMagg_metrics table that has a date dimension event_date_dt, I want to set up anomaly detection on all columns in this table.
This is my config:
models:
- name: agg_metrics
config:
elementary:
timestamp_column: event_date_dt
time_bucket:
period: day # supported periods: day, week, month
count: 1
anomaly_sensitivity: 2.2
anomaly_direction: both
training_period:
period: day # supported periods: day, week, month
count: 90
detection_period:
period: day # supported periods: day, week, month
count: 30
seasonality: day_of_week
tests:
- elementary.all_columns_anomalies:
column_anomalies:
- standard_deviation
- variance
- zero_count
- zero_percent
This is the command I'm running locally (windows):
dbt run -m agg_metrics && dbt test -m agg_metrics && edr report --profiles-dir . --profile-target dev
My report doesn't seem to calculate standard_deviation or variance, and the training period is 338 days.
Any ideas on what I'm doing wrong?kapa.ai
03/16/2025, 10:49 AMkapa.ai
03/16/2025, 10:49 AMNitesh Sharoff
03/16/2025, 11:47 AMkapa.ai
03/16/2025, 11:47 AMkapa.ai
03/16/2025, 11:47 AMmodels.yml), which is the recommended approach for model-specific configurations. According to the knowledge sources, Elementary supports three levels of configuration: 1. Model-level configuration (in your model YAML files) 2. Resource property files (properties.yml) 3. Project-level configuration (dbt_project.yml) However, it's important to note that the configuration should be properly structured. One common issue is incorrect indentation or placement within the YAML file. As mentioned in one of the support conversations: > "I think there is a small issue with indentation with the elementary tests in your schema.yml file, it should be defined under the model and not under 'config'" [Slack forum](https://slack.com/archives/C02CTC89LAX/p1649048906578539) Your configuration appears to be correctly structured with the Elementary config under the model's config section and the tests at the appropriate level. ## Verifying Test Execution Regarding your variance and standard deviation tests, you're correct: > If they're not appearing in data_monitoring_metrics, they're likely not running successfully. This is confirmed by a support conversation where a user had a similar issue: > "We get two new tables generated as output for each tested column, one with name ending in anomaly_scores and one ending with metrics. These contain data only on the sum test currently, nothing else." [Slack forum](https://slack.com/archives/C02CTC89LAX/p1687331770365499) ## Troubleshooting Steps Since you have over 360 days of data, the issue is likely not related to insufficient data. Here are some specific steps to troubleshoot: 1. Check the Elementary test results table to see if there are any error messages: sql select * from <your_elementary_schema>.elementary_test_results where test_short_name = 'column_anomalies' and test_sub_type in ('standard_deviation', 'variance') 2. Verify Elementary package version: Some users experienced issues with column anomaly tests that were fixed in newer versions: # Check in dbt_packages/elementary/dbt_project.yml 3. Try running just one specific test to isolate the issue: dbt test --select agg_metrics --var 'elementary_debug_logs: true' 4. Full refresh of metrics: As mentioned previously, try a full refresh of the metrics table: dbt run --select data_monitoring_metrics --full-refresh If after these steps you're still experiencing issues, it might be worth checking if there are any specific requirements or limitations for the standard_deviation and variance tests that differ from other column anomaly tests. Let me know if these suggestions help or if you need further assistance! I'm here to help you get your Elementary anomaly detection tests working properly. [Slack forum](https://slack.com/archives/C02CTC89LAX/p1687331770365499) [Slack forum](https://slack.com/archives/C02CTC89LAX/p1649048906578539)Nitesh Sharoff
03/16/2025, 11:54 AMkapa.ai
03/16/2025, 11:54 AMkapa.ai
03/16/2025, 11:54 AM