> ## Documentation Index
> Fetch the complete documentation index at: https://docs.elementary-data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Anomaly Tests configuration params

<Card title="Generate your anomaly test with Elementary AI" icon="wand-magic-sparkles" horizontal="true" href="https://elementary-data.com/community">
  Let our Slack chatbot create the anomaly test you need.
</Card>

<Tip>
  If your data set has a timestamp column that represents the creation time of a
  field, it is highly recommended configuring it as a `timestamp_column`.
</Tip>

<pre>
  <code>
    All anomaly detection tests:
    \-- <a href="/data-tests/anomaly-detection-configuration/timestamp-column"><font color="#CD7D55">timestamp\_column: column name</font></a>
    \-- <a href="/data-tests/anomaly-detection-configuration/where-expression"><font color="#CD7D55">where\_expression: sql expression</font></a>
    \-- <a href="/data-tests/anomaly-detection-configuration/anomaly-sensitivity"><font color="#CD7D55">anomaly\_sensitivity: int</font></a>
    \-- <a href="/data-tests/anomaly-detection-configuration/anomaly-direction"><font color="#CD7D55">anomaly\_direction: \[both | spike | drop]</font></a>
    \-- <a href="/data-tests/anomaly-detection-configuration/ignore_small_changes"><font color="#CD7D55">ignore\_small\_changes:</font></a>
        <a href="/data-tests/anomaly-detection-configuration/ignore_small_changes"><font color="#CD7D55">spike\_failure\_percent\_threshold: int</font></a>
        <a href="/data-tests/anomaly-detection-configuration/ignore_small_changes"><font color="#CD7D55">drop\_failure\_percent\_threshold: int</font></a>
    \-- <a href="/data-tests/anomaly-detection-configuration/anomaly-exclude-metrics"><font color="#CD7D55">anomaly\_exclude\_metrics: \[SQL expression]</font></a>

    Anomaly detection tests with timestamp\_column:
    \-- <a href="/data-tests/anomaly-detection-configuration/training-period"><font color="#CD7D55">training\_period: int</font></a>
        <a href="/data-tests/anomaly-detection-configuration/training-period"><font color="#CD7D55">period: \[hour | day | week | month]</font></a>
        <a href="/data-tests/anomaly-detection-configuration/training-period"><font color="#CD7D55">count: int</font></a>
    \-- <a href="/data-tests/anomaly-detection-configuration/detection-period"><font color="#CD7D55">detection\_period: int</font></a>
        <a href="/data-tests/anomaly-detection-configuration/detection-period"><font color="#CD7D55">period: \[hour | day | week | month]</font></a>
        <a href="/data-tests/anomaly-detection-configuration/detection-period"><font color="#CD7D55">count: int</font></a>
    \-- <a href="/data-tests/anomaly-detection-configuration/exclude_detection_period_from_training"><font color="#CD7D55">exclude\_detection\_period\_from\_training: \[true | false]</font></a>
    \-- <a href="/data-tests/anomaly-detection-configuration/time-bucket"><font color="#CD7D55">time\_bucket:</font></a>
        <a href="/data-tests/anomaly-detection-configuration/time-bucket"><font color="#CD7D55">period: \[hour | day | week | month]</font></a>
        <a href="/data-tests/anomaly-detection-configuration/time-bucket"><font color="#CD7D55">count: int</font></a>
    \-- <a href="/data-tests/anomaly-detection-configuration/seasonality"><font color="#CD7D55">seasonality: day\_of\_week</font></a>
    \-- <a href="/data-tests/anomaly-detection-configuration/detection-delay"><font color="#CD7D55">detection\_delay:</font></a>
        <a href="/data-tests/anomaly-detection-configuration/detection-delay"><font color="#CD7D55">period: \[hour | day | week | month]</font></a>
        <a href="/data-tests/anomaly-detection-configuration/detection-delay"><font color="#CD7D55">count: int</font></a>

    dimension\_anomalies, column\_anomalies, all\_columns\_anomalies tests:
    \-- <a href="/data-tests/anomaly-detection-configuration/dimensions"><font color="#CD7D55">dimensions: sql expression</font></a>

    volume\_anomalies test:
    \-- <a href="/data-tests/anomaly-detection-configuration/fail_on_zero"><font color="#CD7D55">fail\_on\_zero: \[true | false]</font></a>

    all\_columns\_anomalies test:
    \-- <a href="/data-tests/anomaly-detection-configuration/column-anomalies"><font color="#CD7D55">column\_anomalies: column monitors list</font></a>
    \-- <a href="/data-tests/anomaly-detection-configuration/exclude_prefix"><font color="#CD7D55">exclude\_prefix: string</font></a>
    \-- <a href="/data-tests/anomaly-detection-configuration/exclude_regexp"><font color="#CD7D55">exclude\_regexp: regex</font></a>

    dimension\_anomalies test:
    \-- <a href="/data-tests/anomaly-detection-configuration/exclude-final-results"><font color="#CD7D55">exclude\_final\_results: \[SQL where expression on fields value / average]</font></a>

    event\_freshness\_anomalies:
    \-- <a href="/data-tests/anomaly-detection-configuration/event_timestamp_column"><font color="#CD7D55">event\_timestamp\_column: column name</font></a>
    \-- <a href="/data-tests/anomaly-detection-configuration/update_timestamp_column"><font color="#CD7D55">update\_timestamp\_column: column name</font></a>
  </code>
</pre>

## Example configurations

<CodeGroup>
  ```yml Models theme={null}
  version: 2

  models:
    - name: <model_name>
      config:
        elementary:
          timestamp_column: < model timestamp column >
      data_tests: < here you will add elementary monitors as tests >

    - name: <your model with no timestamp>
      ## if no timestamp is configured, elementary will monitor without time filtering
      data_tests: <here you will add elementary monitors as tests>
  ```

  ```yml Models example theme={null}
  version: 2

  models:
    - name: login_events
      config:
        elementary:
          timestamp_column: updated_at
      data_tests:
        - elementary.freshness_anomalies:
            config:
              tags: ["elementary"]
        - elementary.all_columns_anomalies:
            config:
              tags: ["elementary"]

    - name: users
      ## if no timestamp is configured, elementary will monitor without time filtering
      data_tests:
        - elementary.volume_anomalies:
            config:
              tags: ["elementary"]
  ```

  ```yml Sources theme={null}
  version: 2

  sources:
    - name: < some name >
      database: < database >
      schema: < schema >
      tables:
        - name: < table_name >
          config:
            elementary:
              timestamp_column: < source timestamp column >
          data_tests: <here you will add elementary monitors as tests>
  ```

  ```yml Sources example theme={null}
  version: 2

  sources:
    - name: "my_non_dbt_table"
      database: "raw_events"
      schema: "product"
      tables:
        - name: "raw_product_login_events"
          config:
            elementary:
              timestamp_column: "loaded_at"
          data_tests:
            - elementary.volume_anomalies
            - elementary.all_columns_anomalies:
                arguments:
                  column_anomalies:
                    - null_count
                    - missing_count
                    - zero_count
          columns:
            - name: user_id
              data_tests:
                - elementary.column_anomalies
  ```
</CodeGroup>
