Connie Wang
06/10/2026, 8:58 PMkapa.ai
06/10/2026, 8:58 PMelementary.collect_metrics test. [Metrics docs]
Here's how it works:
• Metrics are defined in code (like dbt tests) and collected each time you run dbt test.
• You can monitor any metric on your data content, view it in the Metrics screen, and set up anomaly detection on it.
• A metric can be collected with or without an anomaly detection test configured.
Example configuration data_tests:
- elementary.collect_metrics:
arguments:
timestamp_column: your_timestamp_column
time_bucket:
period: day
count: 1
dimensions: sql_expression # optional grouping
metrics:
- name: my_custom_metric
type: monitor_type # e.g. sum, avg, etc.
columns: [col1, col2]
where_expression: sql_expression # optional filter
[Metrics docs]
A few notes: • This feature is available on Elementary Cloud.
• To include alerts for metric anomalies in your alert rules, edit your alert rule and check the "Metric anomalies" box under "Test Categories".
• If you need to monitor a custom calculated value (e.g., a ratio or match rate between tables) that isn't a simple column, the recommended approach is still to materialize it as a dbt model first, then apply the test to it.
So the short answer is: yes, this has been addressed — custom metric collection with anomaly detection is now supported in Elementary Cloud. 👍 0 button 👎 0 button ℹ️ Tip: Mention @elementary.ai in the thread for follow-ups or DM the app for 1-to-1 help.Connie Wang
06/10/2026, 9:00 PMmetric_name: roi
sql: sum(revenue) / sum(cost)kapa.ai
06/10/2026, 9:00 PMelementary.collect_metrics is indeed limited to the pre-defined monitor types — it does not support arbitrary SQL expressions like sum(revenue) / sum(cost) as a custom metric definition. [Metrics docs]
For a fully custom SQL metric like your roi example, the knowledge sources do not indicate that this is natively supported. The workaround consistently recommended in the community is to materialize the calculation as a column in a dbt model first, then apply anomaly detection to that column:
1. Create a dbt model that computes your ratio:-- models/daily_roi.sql
select
date_column,
sum(revenue) / nullif(sum(cost), 0) as roi
from your_table
group by date_column
2. Apply an Elementary anomaly test to the roi columnmodels
- name: daily_roi
columns:
- name: roi
tests:
- elementary.column_anomalies:
timestamp_column: date_column
[Slack discussion]
I'm sorry, but the knowledge sources don't contain enough information to confirm whether the specific sql: syntax from the GitHub issue you referenced has been implemented. I'd recommend checking the GitHub issue directly or asking in the Elementary community Slack for the latest status. 👍 0 button 👎 0 button ℹ️ Tip: Mention @elementary.ai in the thread for follow-ups or DM the app for 1-to-1 help.