<@U088WCP3B4P> If i have this test below in dbt: d...
# ask-elementary-ai
y
@kapa.ai If i have this test below in dbt: data_tests: - elementary.volume_anomalies: config: severity: error warn_if: ">0" error_if: ">10" meta: channel: r arguments: ignore_small_changes: spike_failure_percent_threshold: 10 drop_failure_percent_threshold: 10 1. what does the setting mean if we already set severity: error and we still put warn_if: ">0"? Are they contradictory? 2. if we have a spike of 12 rows in the result, the spike_failure_percent_threshold is 10% and 10% is around 100, then will there be an error alert or not in the channel?
k
Answers to Your Questions 1. Does severity: error contradict warn_if: ">0"? They are not necessarily contradictory, but the interaction can be confusing. Here's how dbt's severity system works: •
severity
sets the default outcome when a test fails (i.e., when neither
warn_if
nor
error_if
explicitly matches). •
warn_if
and
error_if
define row-count thresholds that override the default severity based on how many failing rows are returned. So with your config: •
warn_if: ">0"
→ warn if the result has more than 0 rows •
error_if: ">10"
→ error if the result has more than 10 rows •
severity: error
→ the base severity In practice,
error_if
takes precedence over
warn_if
when both conditions are met. So if the result is >10 rows, it errors; if it's between 1–10 rows, it warns. The
severity: error
here is somewhat redundant given you've explicitly set both thresholds, but it's not contradictory. > ⚠️ Important caveat for Elementary anomaly tests: The knowledge sources note that
error_if
/
warn_if
won't work as expected with Elementary anomaly detection tests because of how they are implemented — dbt's `error_if`/`warn_if` looks at the number of rows returned from the test query, not the anomaly value itself. [Slack: severity on anomaly tests] 2. Will a spike of 12 rows trigger an error alert in the channel? This depends on two separate layers: Layer 1 —
ignore_small_changes
(does the test fail at all?)
With
spike_failure_percent_threshold: 10
, the test will only fail if both conditions are true: 1. The z-score is anomalous (statistically significant spike), AND 2. The spike is more than 10% above the training period mean If your table has ~1,000 rows and 10% ≈ 100 rows, then a spike of only 12 rows (~1.2%) would not exceed the 10% threshold — so the test would pass and no alert would be sent, regardless of severity settings. [ignore_small_changes docs] Layer 2 —
error_if: ">10"
(what severity if the test does fail?)
As noted above, `error_if`/`warn_if` on Elementary anomaly tests don't behave as expected because they count result rows, not anomaly magnitude. So even if the test did fail, the
error_if: ">10"
threshold may not work reliably for Elementary tests. [Slack: severity on anomaly tests] Recommendation If you want explicit percentage-based warn/error thresholds for volume changes, consider using elementary.volume_threshold instead, which has built-in dual severity via
warn_threshold_percent
and
error_threshold_percent
— designed exactly for this use case. [volume_threshold docs] 👍 0 button 👎 0 button ℹ️ Tip: Mention @elementary.ai in the thread for follow-ups or DM the app for 1-to-1 help.
y
@kapa.ai can we define both warn and error conditions in a same volume_anomalies test or not?
k
Defining Both Warn and Error in a Single volume_anomalies Test No, you cannot define both warn and error conditions in a single
elementary.volume_anomalies
test.
As noted in the knowledge sources,
error_if
/
warn_if
won't work as expected with Elementary anomaly tests because of how they are implemented — dbt's `error_if`/`warn_if` looks at the number of rows returned from the test query, not the anomaly value itself. [Slack: severity on anomaly tests] Recommended Workaround Define two separate tests with different
anomaly_sensitivity
values and set their
severity
accordingly:
Copy code
- elementary.volume_anomalies:
    anomaly_sensitivity: 1
    config:
      severity: warn
- elementary.volume_anomalies:
    anomaly_sensitivity: 3
    config:
      severity: error
The test with lower sensitivity will trigger a warning for softer anomalies, and the test with higher sensitivity will trigger an error for more significant ones. [Slack: workaround] Alternative: Use volume_threshold Instead If you need explicit percentage-based dual severity in a single test, consider elementary.volume_threshold, which has built-in support for both
warn_threshold_percent
and
error_threshold_percent
in one test configuration:
Copy code
data_tests:
  - elementary.volume_threshold:
      arguments:
        timestamp_column: your_timestamp_column
        warn_threshold_percent: 5
        error_threshold_percent: 10
[volume_threshold docs] 👍 0 button 👎 0 button ℹ️ Tip: Mention @elementary.ai in the thread for follow-ups or DM the app for 1-to-1 help.
y
@kapa.ai so with the setting, both warns and errors would be sent to a same channel?
k
Channel Routing for Warns and Errors Yes, with the two-test workaround, both warnings and errors would be sent to the same channel if you define
meta.channel
the same way on both tests (or inherit it from the model/source level). Routing Warns and Errors to Different Channels If you want warns and errors sent to different channels, the knowledge sources indicate there is no way to do this purely through test configuration. The recommended approach is to run two separate
edr monitor
commands
with status filters:
Copy code
edr monitor --select 'statuses:warn' --slack-channel-name 'warn-channel'
edr monitor --select 'statuses:fail' --slack-channel-name 'error-channel'
[Slack: routing to different channels; Slack: two edr runs] Alternatively, you can set a different
meta.channel
on each of the two separate tests directly:
Copy code
- elementary.volume_anomalies:
    anomaly_sensitivity: 1
    config:
      severity: warn
    meta:
      channel: warn-channel

- elementary.volume_anomalies:
    anomaly_sensitivity: 3
    config:
      severity: error
    meta:
      channel: error-channel
However, the knowledge sources suggest this per-test channel approach may not reliably separate warns from errors in all cases, and the
edr monitor
with status filters is the more reliable method
. [Slack: routing to different channels] 👍 0 button 👎 0 button ℹ️ Tip: Mention @elementary.ai in the thread for follow-ups or DM the app for 1-to-1 help.