<@U088WCP3B4P> Can you write a sample anomaly test...
# ask-elementary-ai
d
@kapa.ai Can you write a sample anomaly test based on 2 dimensions ( country and date)
k
Thinking completed Here is a sample
dimension_anomalies
test using two dimensions —
country
and `date`:
Copy code
models:
  - name: your_model_name
    config:
      elementary:
        timestamp_column: updated_at
    data_tests:
      - elementary.dimension_anomalies:
          arguments:
            dimensions:
              - country
              - date
          config:
            tags: ["elementary"]
            severity: warn
A few important things to keep in mind when using two dimensions together: [dimensions config] • Combinations are watched, not individual columns. Elementary joins the two values with
;
and monitors every combination it finds — e.g.,
US; 2026-01-01
,
DE; 2026-01-01
, etc. This is not the same as monitoring
country
and
date
separately. [understanding dimension anomalies] •
date
is likely high-cardinality.
Since
date
can have many distinct values, combining it with
country
will produce a very large number of combinations (e.g., 20 countries × 365 dates = 7,300 combinations). This can lead to significant noise and false alarms. It is generally recommended to use low-cardinality fields as dimensions. [dimension_anomalies test] • Order matters. If you ever reorder, add, or remove a column from the
dimensions
list, Elementary will lose its historical data and start collecting from scratch. [understanding dimension anomalies] • To monitor each field independently, write two separate tests instead of listing both columns in one test. 👍 0 button 👎 0 button ℹ️ Tip: Mention @elementary.ai in the thread for follow-ups or DM the app for 1-to-1 help.