<@U088WCP3B4P> Similar to <this question>, we have...
# ask-elementary-ai
m
@kapa.ai Similar to this question, we have multiple dbt runs/build which are execute different models via different selection methods (sometimes by tag, sometimes by path etc.). I would like to set up Elementary Alerts to receive notifications via Slack in case of a model or test failure. The notifications should only contain the models and tests for a specific dbt run. How do I do that?
k
A message from kapa.ai
Based on the knowledge sources, you can achieve this by running separate
edr monitor
commands after each specific dbt run, using selectors to filter alerts. Here are your options: ## Approach 1: Use Tags with Selectors If your different dbt runs use tags to select models, you can run
edr monitor
with tag filters after each run:
Copy code
bash # After your first dbt run with specific tags edr monitor --filters tags:finance  # After your second dbt run with different tags edr monitor --filters tags:marketing
The
--filters
flag supports multiple filter types including tags, owners, models, and resource types. You can also combine filters using multiple
--filters
flags (combined with AND logic) or use commas for OR logic within the same filter type. ## Approach 2: Use Model/Path Selectors You can also filter by specific models or use dbt's selection syntax:
Copy code
bash edr monitor --select model:specific_model_name
## How It Works As explained in the [Slack discussion](https://slack.com/archives/C02CTC89LAX/p1672236535325579), Elementary marks alerts as "sent" after each
edr monitor
execution, so it will only notify on new alerts each time. This means: 1. Run your first dbt command (e.g.,
dbt build --select tag:finance
) 2. Run
edr monitor --filters tags:finance
- this sends alerts only for models/tests from that run 3. Run your second dbt command (e.g.,
dbt build --select path:marketing/
) 4. Run
edr monitor --filters tags:marketing
- this sends alerts only for the new run ## Additional Configuration You can also route alerts to different Slack channels per business unit or team by running separate monitor commands with different channel configurations:
Copy code
bash edr monitor --filters tags:finance --slack-channel-name finance_alerts edr monitor --filters tags:marketing --slack-channel-name marketing_alerts
For more details on filtering options, see the [alerts configuration documentation](https://docs.elementary-data.com/oss/guides/alerts/alerts-configuration#alerts-cli-flags).
m
@kapa.ai Thanks. When using tags, do the tests referenced to a model need to have the same tag as the model or will notifications get sent for every test as long as the model has the same tag I am using for selection in the
edr monitor --filters
command?
k
A message from kapa.ai
Based on the knowledge sources, tests do NOT need to have the same tag as their parent model to be included in alerts. Elementary will send notifications for all tests on a model as long as the model itself has the tag you're filtering by. ## How Tag Inheritance Works According to the [alerts configuration documentation](https://docs.elementary-data.com/oss/guides/alerts/alerts-configuration#alert-properties-in-yml-files), Elementary follows a configuration priority order: For tests: 1. Test properties 2. Tests path configuration under
tests
key in
dbt_project.yml
3. Parent model configuration Additionally, the documentation explicitly states that "Tags are aggregated, so a test alert will include both the test and the parent model tags." ## Practical Example This means if you have:
Copy code
yaml models:   - name: my_finance_model     tags: ["finance"]     columns:       - name: amount         tests:           - not_null  # This test doesn't have a "finance" tag
When you run:
Copy code
bash edr monitor --filters tags:finance
The
not_null
test on
my_finance_model
will be included in the alerts because its parent model has the
finance
tag. ## Confirmation from Community This is confirmed in a [Slack discussion](https://slack.com/archives/C02CTC89LAX/p1684317197934859) where a support staff member explains: "The tags on the Slack alerts should be a combination of the test tags and the depend on nodes (models/sources) tags." So you only need to tag your models, and all tests on those models will automatically be included when filtering by that tag.
m
@kapa.ai Thanks. Can I also limit the notifications so that test with
severity: warn
are not included?
k
A message from kapa.ai
Yes, you can exclude tests with
severity: warn
from notifications. There are two main approaches: ## Approach 1: Use the Status Filter (Recommended) You can filter alerts by status when running
edr monitor
. To exclude warnings and only get error notifications:
Copy code
bash edr monitor --filters tags:finance --select statuses:fail
Or if you want to be more explicit:
Copy code
bash edr monitor --filters tags:finance --select statuses:error
This approach is confirmed in multiple [Slack discussions](https://slack.com/archives/C02CTC89LAX/p1698434621093649) where users successfully filtered by status. ## Approach 2: Disable Warn Alerts Globally You can disable warning alerts entirely by setting a variable in your `dbt_project.yml`:
Copy code
yaml vars:   disable_warn_alerts: true
However, this approach has an important caveat: as explained in a [Slack discussion](https://slack.com/archives/C02CTC89LAX/p1673893162838399), disabling alerts in the dbt project only affects the collection of new alerts. If alerts were already collected in Elementary's tables, they will still be sent. The change takes effect from the second run onwards. ## Combining Filters You can combine both tag filters and status filters together:
Copy code
bash edr monitor --filters tags:finance --select statuses:fail --slack-channel-name finance_alerts
This will send only error-level alerts (excluding warnings) for models tagged with
finance
to your specified Slack channel. ## Note on Routing Different Severities If you want to route warnings and errors to different channels instead of excluding warnings entirely, you can run two separate
edr monitor
commands as shown in [this discussion](https://slack.com/archives/C02CTC89LAX/p1701288882334569):
Copy code
bash edr monitor --filters tags:finance --select statuses:warn --slack-channel-name finance_warnings edr monitor --filters tags:finance --select statuses:fail --slack-channel-name finance_errors