> ## Documentation Index
> Fetch the complete documentation index at: https://elementary-more-explicit-webhook-instructions.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# freshness_anomalies

`elementary.freshness_anomalies`

Monitors the freshness of your table over time, as the expected time between data updates.

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 maximum freshness value per bucket for the last `training_period` (by default 14 days).

The test then compares the freshness of each bucket within the detection period (last 2 days by default, controlled by the
`detection_period` var), and compares it to the freshness of the previous time buckets.
If there were any anomalies during the detection period, the test will fail.

### Test configuration

*Required configuration: `timestamp_column`*
*Default configuration: `anomaly_direction: spike` to alert only on delays.*

{/* prettier-ignore */}

<pre>
  <code>
    tests:
      -- elementary.freshness\_anomalies:
        <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/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/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/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>
  </code>
</pre>

<RequestExample>
  ```yml Models
  models:
    - name: < model name >
      tests:
        - elementary.freshness_anomalies:
            timestamp_column: < timestamp column > # Mandatory
            where_expression: < sql expression >
            time_bucket: # Daily by default
              period: < time period >
              count: < number of periods >
  ```

  ```yml Models example
  models:
    - name: login_events
      tests:
        - elementary.freshness_anomalies:
            timestamp_column: "updated_at"
            # optional - use tags to run elementary tests on a dedicated run
            tags: ["elementary"]
            config:
              # optional - change severity
              severity: warn
  ```
</RequestExample>
