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

# Alerts Configuration and Customization

You can enrich your alerts by adding properties to tests, models and sources in your `.yml` files.
The supported attributes are: [owner](#Owner),
[subscribers](#Subscribers),
[description](#Test-description),
[tags](#Tags).

You can configure and customize your alerts by configuring:
[custom channel](#Custom-channel),
[suppression interval](#Suppression-interval),
[alert fields](#Alert-fields)(for test alerts only), [alert grouping](#Group-alerts-by-table),
[alert filters](#Filter-alerts).

## Alert properties in `.yml` files

Elementary prioritizes configuration in the following order:

**For models / sources:**

1. Model config block.
2. Model properties.
3. Model path configuration under `models` key in `dbt_project.yml`.

**For tests:**

1. Test properties.
2. Tests path configuration under `tests` key in `dbt_project.yml`.
3. Parent model configuration.

<pre>
  <code>
    meta:
      <a href="./alerts-code-configuration#owner"><font color="#CD7D55">owner: "@jessica.jones"</font></a>
      <a href="./alerts-code-configuration#subscribers"><font color="#CD7D55">subscribers: \["@jessica.jones", "@joe.joseph"]</font></a>
      <a href="./alerts-code-configuration#test-description"><font color="#CD7D55">description: "This is the test description"</font></a>
      <a href="./alerts-code-configuration#tags"><font color="#CD7D55">tags: \["#marketing", "#data\_ops"]</font></a>
      <a href="./alerts-code-configuration#custom-channel"><font color="#CD7D55">channel: data\_ops</font></a>
      <a href="./alerts-code-configuration#suppression-interval"><font color="#CD7D55">alert\_suppression\_interval: 24</font></a>
      <a href="./alerts-code-configuration#group-alerts-by-table"><font color="#CD7D55">slack\_group\_alerts\_by: table</font></a>
      <a href="./alerts-code-configuration#alert-fields"><font color="#CD7D55">alert\_fields: \["description", "owners", "tags", "subscribers", ...]</font></a>
  </code>
</pre>

### Alert content

#### Owner

Elementary enriches alerts with [owners for models or tests](https://docs.getdbt.com/reference/resource-configs/meta#designate-a-model-owner)).

* If you want the owner to be tagged on slack use '@' and the email prefix of the slack user (@jessica.jones to tag [jessica.jones@marvel.com](mailto:jessica.jones@marvel.com)).
* You can configure a single owner or a list of owners (`["@jessica.jones", "@joe.joseph"]`).

<CodeGroup>
  ```yml model theme={null}
  models:
    - name: my_model_name
      config:
        meta:
          owner: "@jessica.jones"
  ```

  ```yml test theme={null}
  data_tests:
    - not_null:
      config:
        meta:
          owner: ["@jessica.jones", "@joe.joseph"]
  ```

  ```yml test/model config block theme={null}
  {{ config(
      tags=["Tag1","Tag2"]
      meta={
          "description": "This is a description",
          "owner": "@jessica.jones"
      }
  ) }}
  ```

  ```yml dbt_project.yml theme={null}
  models/sources:
    path:
      subfolder:
        +meta:
          owner: "@jessica.jones"

  data_tests:
    path:
      subfolder:
        +meta:
          owner: "@jessica.jones"

  # table level:

  sources:
    - name: source_name
      database: db
      schema: schema
      tables:
        - name: orders
          meta:
            owner: "@jessica.jones"


  ```
</CodeGroup>

#### Subscribers

If you want additional users besides the owner to be tagged on an alert, add them as subscribers.

* If you want the subscriber to be tagged on slack use '@' and the email prefix of the slack user (@jessica.jones to tag [jessica.jones@marvel.com](mailto:jessica.jones@marvel.com)).
* You can configure a single subscriber or a list (`["@jessica.jones", "@joe.joseph"]`).

<CodeGroup>
  ```yml model theme={null}
  models:
    - name: my_model_name
      config:
        meta:
          subscribers: "@jessica.jones"
  ```

  ```yml test theme={null}
  data_tests:
    - not_null:
      config:
        meta:
          subscribers: ["@jessica.jones", "@joe.joseph"]
  ```

  ```yml test/model config block theme={null}
  {{ config(
      meta={
          "subscribers": "@jessica.jones"
      }
  ) }}
  ```

  ```yml dbt_project.yml theme={null}
  models:
    path:
      subfolder:
        +meta:
          subscribers: "@jessica.jones"

  data_tests:
    path:
      subfolder:
        +meta:
          subscribers: "@jessica.jones"
  ```
</CodeGroup>

#### Test description

Elementary supports configuring description for tests that are included in alerts.
It's recommended to add an explanation of what does it mean if this test fails, so alert will include this context.

<CodeGroup>
  ```yml test theme={null}
  data_tests:
    - not_null:
      config:
        meta:
          description: "This is the test description"
  ```

  ```yml test config block theme={null}
  {{ config(
      tags=["Tag1","Tag2"]
      meta={
          description: "This is the test description"
      }
  ) }}
  ```

  ```yml dbt_project.yml theme={null}
  data_tests:
    path:
      subfolder:
        +meta:
          description: "This is the test description"
  ```
</CodeGroup>

#### Tags

You can use [tags](https://docs.getdbt.com/reference/resource-configs/tags) to provide context to your alerts.

* You can tag a group or a channel in a slack alert by adding `#channel_name` as a tag.
* Tags are aggregated,so a test alert will include both the test and the parent model tags.

<CodeGroup>
  ```yml model theme={null}
  models:
    - name: my_model_name
      tags: ["#marketing", "#data_ops"]
  ```

  ```yml test theme={null}
  data_tests:
    - not_null:
      tags: ["#marketing", "#data_ops"]
  ```

  ```yml test/model config block theme={null}
  {{ config(
      tags=["#marketing", "#data_ops"]
      }
  ) }}
  ```

  ```yml dbt_project.yml theme={null}
  models:
    path:
      subfolder:
        tags: ["#marketing", "#data_ops"]

  data_tests:
    path:
      subfolder:
        tags: ["#marketing", "#data_ops"]
  ```
</CodeGroup>

### Alerts distribution

Elementary allows you to customize alerts to distribute the right information to the right people.
This way you can ensure your alerts are valuable and avoid alert fatigue.

#### Custom channel

Elementary supports configuring custom Slack channels for models and tests.
By default, Elementary uses the Slack channel that was configured in the Slack integration. Even if
a custom channel is defined for every test, you must specify a default fallback channel, either using
the CLI or the `config.yml` file.

<CodeGroup>
  ```yml model theme={null}
  models:
    - name: my_model_name
      config:
        meta:
          channel: data_ops
  ```

  ```yml test theme={null}
  data_tests:
    - not_null:
      config:
        meta:
          channel: data_ops
  ```

  ```yml test/model config block theme={null}
  {{ config(
      meta={
          "channel": "data_ops"
      }
  ) }}
  ```

  ```yml dbt_project.yml theme={null}
  models:
    path:
      subfolder:
        +meta:
          channel: data_ops

  data_tests:
    path:
      subfolder:
        +meta:
          channel: data_ops
  ```
</CodeGroup>

#### Suppression interval

Don’t want to get multiple alerts if the same test keeps failing?
You can now configure an `alert_suppression_interval`, this is a “snooze” period for alerts on the same issue.

The accepted value is in hours, so 1 day snooze is `alert_suppression_interval: 24`.
Elementary won't send new alerts on the same issue that are generated within suppression interval.

Note: if you configure a suppression interval using this method, it will override the value in the global configuration.

<CodeGroup>
  ```yml model theme={null}
  models:
    - name: my_model_name
      config:
        meta:
          alert_suppression_interval: 24
  ```

  ```yml test theme={null}
  data_tests:
    - not_null:
      config:
        meta:
          alert_suppression_interval: 12
  ```

  ```yml test/model config block theme={null}
  {{ config(
      meta={
          "alert_suppression_interval": 24
      }
  ) }}
  ```

  ```yml dbt_project.yml theme={null}
  models:
    path:
      subfolder:
        +meta:
          alert_suppression_interval: 24

  data_tests:
    path:
      subfolder:
        +meta:
          alert_suppression_interval: 48
  ```
</CodeGroup>

#### Group alerts by table

By default, Elementary sends a single alert to notify on each failure with extensive information for fast triage.

Elementary also supports grouping alerts by table.
In this case, a single Slack notification will be generated containing all issues associated with this table.
The created notification will contain a union of the relevant owners, tags and subscribers.

Due to their nature, grouped alerts will contain less information on each issue.

<CodeGroup>
  ```yml model theme={null}
  models:
    - name: my_model_name
      config:
        meta:
          slack_group_alerts_by: table
  ```

  ```yml test theme={null}
  data_tests:
    - not_null:
      config:
        meta:
          slack_group_alerts_by: table
  ```

  ```yml test/model config block theme={null}
  {{ config(
      meta={
          "slack_group_alerts_by": "table"
      }
  ) }}
  ```

  ```yml dbt_project.yml theme={null}
  models:
    path:
      subfolder:
        +meta:
          slack_group_alerts_by: table

  data_tests:
    path:
      subfolder:
        +meta:
          slack_group_alerts_by: table
  ```
</CodeGroup>

#### Alert fields

<Warning>**Currently this feature is supported only by test alerts!**</Warning>

You can decide which fields to include in the alert, and create a format of alert that fits your use case and recipients.\
By default, all the fields are included in the alert.

Supported alert fields:

* table: Displays the table name of the test
* column: Displays the column name of the test
* description: Displays the description of the test
* owners: Displays the owners of the model on which the test is running
* tags: Displays the dbt tags of the test/model
* subscribers: Displays the subscribers of the test/model
* result\_message: Displays the returned message from the test result
* test\_parameters: Displays the parameters that were provided to the test
* test\_query: Displays the query of the test
* test\_results\_sample: Displays a sample of the test results

<CodeGroup>
  ```yml model theme={null}
  models:
    - name: my_model_name
      config:
        meta:
          alert_fields: ["description", "owners", "tags", "subscribers"]
  ```

  ```yml test theme={null}
  data_tests:
    - not_null:
      config:
        meta:
          alert_fields: ["description", "owners", "tags", "subscribers"]
  ```

  ```yml test/model config block theme={null}
  {{ config(
      meta={
          "alert_fields": "['description', 'owners', 'tags', 'subscribers']"
      }
  ) }}
  ```

  ```yml dbt_project.yml theme={null}
  models:
    path:
      subfolder:
        +meta:
          alert_fields: ["description", "owners", "tags", "subscribers"]

  data_tests:
    path:
      subfolder:
        +meta:
          alert_fields: ["description", "owners", "tags", "subscribers"]
  ```
</CodeGroup>

<Warning>
  Alert vars are deprecated! We recommend filtering the alerts
  using [CLI selectors](/oss/guides/alerts/alerts-configuration#alerts-cli-flags)
  instead.
</Warning>

## Alerts CLI flags

<Warning>
  Alert vars are deprecated! We recommend filtering the alerts
  using CLI selectors instead.
</Warning>

#### Filter alerts

Elementary supports filtering the alerts by tag, owner, model, status or resource type.

Using filters, you can send alerts to the relevant people and teams by running `edr` multiple times with different filters on each run.

<Info>
  Alerts on skipped tests and models are filtered out by default. if you want to receive those alerts, apply the statuses filter and include them explicitly.
</Info>

<CodeGroup>
  ```shell tags filter theme={null}
  edr monitor --filters tags:critical
  edr monitor --filters tags:finance,marketing
  ```

  ```shell owners filter theme={null}
  edr monitor --filters owners:@jeff
  edr monitor --filters owners:@jessy,@jeff
  ```

  ```shell models filter theme={null}
  edr monitor --filters models:customers
  edr monitor --filters models:orders,customers,signups
  ```

  ```shell statuses filter theme={null}
  edr monitor --filters statuses:warn,fail
  edr monitor --filters statuses:error
  edr monitor --filters statuses:skipped
  ```

  ```shell resource_types filter theme={null}
  edr monitor --filters resource_types:model
  edr monitor --filters resource_types:test
  edr monitor --filters resource_types:test,source_freshness
  ```
</CodeGroup>

The `--filters` flag can be used multiple times to apply multiple filters. The filters are combined using the logical AND operator.
The comma `,` is used to separate multiple values for the same filter, creating a logical OR.

<CodeGroup>
  ```shell multiple filters theme={null}
  edr monitor --filters resource_types:model --filters tags:finance,marketing
  ```
</CodeGroup>

#### Group alerts by table

By default, Elementary sends a single alert to notify on each failure with extensive information for fast triage.

Elementary also supports grouping alerts by table.
In this case, a single Slack notification will be generated containing all issues associated with this table.
The created notification will contain a union of the relevant owners, tags and subscribers.

Due to their nature, grouped alerts will contain less information on each issue.

```shell theme={null}
edr monitor --group-by table
```

#### Suppression interval flag

Don’t want to get multiple alerts if the same test keeps failing?
You can now configure an alert\_suppression\_interval, this is a “snooze” period for alerts on the same issue.
Elementary won’t send new alerts on the same issue that are generated within suppression interval.

The flag configuration is the suppression interval duration in hours, and the default is 0 hours (no alert suppression).
If configured otherwise in the dbt project config block or meta, the CLI value will be ignored (unless `--override-dbt-project-config` is used).

```shell theme={null}
edr monitor --suppression-interval 24
```

#### Alert group threshold

Set a minimum alert threshold before grouping notifications into a summary alert — keeping noise low while ensuring nothing gets missed.

```shell theme={null}
edr monitor --group-alerts-threshold 5
```
