generate anomaly detection that mimics this pseudo...
# ask-elementary-ai
j
generate anomaly detection that mimics this pseudo code SUM(taya_cnt) FROM publish.publish_report WHERE reporting_date = TIMESTAMP(CURRENT_DATE()) GROUP BY DATE(reporting_date)
k
A message from kapa.ai
Based on your request, you're looking to set up anomaly detection in Elementary Data that monitors the sum of a column (
taya_cnt
) grouped by date. Elementary Data offers several options for anomaly detection, and for your specific use case, you'll want to use column anomalies with the sum metric. Here's how you can implement this:
Copy code
yaml models:   - name: publish_report     config:       elementary:         timestamp_column: "reporting_date"     columns:       - name: taya_cnt         tests:           - elementary.column_anomalies:               column_anomalies:                 - sum               time_bucket:                 period: day                 count: 1               where_expression: "DATE(reporting_date) = CURRENT_DATE()"               config:                 severity: warn
This configuration will: 1. Monitor the
taya_cnt
column in your
publish_report
model 2. Calculate the sum of this column for each day 3. Apply the where condition to filter for the current date 4. Compare this sum against historical patterns to detect anomalies If you need to monitor this metric for different dimensions (like grouping by another column), you should know that Elementary is planning to add support for dimension-based column metrics in the future [Github Issue](https://github.com/elementary-data/elementary/issues/764). Currently, the
dimension_anomalies
test only supports row count metrics, not sum or other aggregations. As an alternative approach, you could create a pre-aggregated model that calculates your daily sums first, and then apply anomaly detection to that model, as suggested in several community discussions [Slack forum discussion](https://slack.com/archives/C02CTC89LAX/p1702591423091109). Would you like more information about configuring the sensitivity of the anomaly detection or other parameters?