> ## 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.

# volume_anomalies

<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>

`elementary.volume_anomalies`

Monitors the row count of your table over time per time bucket (if configured without `timestamp_column`, will count table total rows).

Upon running the test, your data is split into time buckets (daily by default, configurable with the `time bucket` field),
and then we compute the row count per bucket for the last [`training_period`](/data-tests/anomaly-detection-configuration/training-period) days (by default 14).

The test then compares the row count of each bucket within the detection period (last 2 days by default, configured as [`detection_period`](/data-tests/anomaly-detection-configuration/detection-period)),
and compares it to the row count of the previous time buckets.

**The test will only run on completed time buckets**, so if you run it with daily buckets in the middle of today, the test would only count yesterday as a complete bucket.
If there were any anomalies during the detection period, the test will fail.

### Test configuration

No mandatory configuration, however it is highly recommended to configure a `timestamp_column`.

<pre>
  <code>
    data\_tests:
      - elementary.volume\_anomalies:
        arguments:
          <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/detection-period"><font color="#CD7D55">detection\_period:</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/training-period"><font color="#CD7D55">training\_period:</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/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/fail_on_zero"><font color="#CD7D55">fail\_on\_zero: \[true | false]</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/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>
          <a href="/data-tests/anomaly-detection-configuration/anomaly-exclude-metrics"><font color="#CD7D55">anomaly\_exclude\_metrics: \[SQL expression]</font></a>
  </code>
</pre>

<RequestExample>
  ```yml Models theme={null}
  models:
    - name: < model name >
      data_tests:
        - elementary.volume_anomalies:
            arguments:
              timestamp_column: < timestamp column >
              where_expression: < sql expression >
              time_bucket: # Daily by default
                period: < time period >
                count: < number of periods >
  ```

  ```yml Models example theme={null}
  models:
    - name: login_events
      config:
        elementary:
          timestamp_column: "loaded_at"
      data_tests:
        - elementary.volume_anomalies:
            arguments:
              where_expression: "event_type in ('event_1', 'event_2') and country_name != 'unwanted country'"
              time_bucket:
                period: day
                count: 1
            config:
              # optional - use tags to run elementary tests on a dedicated run
              tags: ["elementary"]
              # optional - change severity
              severity: warn

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