How do I set up Elementary monitoring via Slack al...
# ask-elementary-ai
a
How do I set up Elementary monitoring via Slack alerts when I have multiple dbt profiles? I have a
prod
profile and an additional one called
uat
, and I need monitoring and alerts on both. We have also altered the generate_schema_name macro to add a prefix to schema names for the uat profile, like so:
Copy code
{%- elif target.name == 'uat' -%}
        uat_{{ generate_schema_name_for_env(custom_schema_name, node) }}
 {%- endif -%}
I have set up elementary output profiles in the
profiles.yml
file, but only for
prod
, do I need to set one up for uat too? Currently elementary Slack alerting works for
prod
, but not for jobs running under the
uat
profile
k
New message text here
a
@kapa.ai can you explain how the Elementary profiles work and what backend tables are populated that are used for Slack alerting?
k
How Elementary Profiles Work The elementary Profile in profiles.yml Elementary requires a dedicated connection profile named
elementary
in your
profiles.yml
file. This is separate from your main dbt project profile(s) (e.g.,
prod
,
uat
). The
edr
CLI looks specifically for a profile named
elementary
to know where to connect to the data warehouse. [CLI install guide] The easiest way to generate it is:
Copy code
dbt run-operation elementary.generate_elementary_cli_profile
A typical multi-environment setup looks like this:
Copy code
# Your existing dbt project profile
my_project:
  target: prod
  outputs:
    prod:
      type: snowflake
      schema: my_schema
      # ...
    uat:
      type: snowflake
      schema: uat_my_schema
      # ...

# Elementary's dedicated profile (top-level, same indentation)
elementary:
  target: prod
  outputs:
    prod:
      type: snowflake
      schema: my_schema_elementary  # must match where Elementary tables are created
      # ...
    uat:
      type: snowflake
      schema: uat_my_schema_elementary  # must match where Elementary tables are created for uat
      # ...
The
elementary
profile block must be a top-level entry, at the same indentation level as your other profiles. [Slack discussion] Key Rule: Schema Must Match Exactly The
schema
value in the
elementary
profile must literally match the schema where the Elementary dbt package tables are physically created. The
edr
CLI does not use your custom
generate_schema_name
macro — it only reads the static schema value from the
elementary
profile. [GitHub issue] This is why, in your case, you need to set the
schema
for the
uat
target to whatever schema your custom macro resolves to (e.g.,
uat_my_schema_elementary
). Selecting the Right Target Use the
--profile-target
(or
-t
) flag to tell
edr
which target to use within the
elementary
profile:
Copy code
edr monitor --profile-target prod   # uses prod Elementary tables
edr monitor --profile-target uat    # uses uat Elementary tables
The
--env
flag is purely cosmetic — it only controls the label shown in reports and Slack alerts, not which database/schema is used. [Slack discussion] Backend Tables Populated for Slack Alerting The Elementary dbt package writes its data into the schema you configure (e.g.,
my_schema_elementary
). The key table used for alerting is
elementary_test_results
, which stores the outcomes of your dbt test runs. [CLI install guide] More broadly, the Elementary package creates various models to store: • dbt artifacts (metadata about your project, models, sources) • test results (pass/fail outcomes, anomaly detection results) • run results (collected automatically as part of your dbt runs) These are populated when you run
dbt test
,
dbt build
, or
dbt run
with the Elementary package installed. The
edr monitor
command then reads from these tables (via the
elementary
profile) to generate and send Slack alerts. [Elementary in production] The knowledge sources do not provide an exhaustive list of every backend table, but
elementary_test_results
is explicitly mentioned as the primary table the CLI reads from to determine alert content. 👍 0 button 👎 0 button ℹ️ Tip: Mention @elementary.ai in the thread for follow-ups or DM the app for 1-to-1 help.
a
@kapa.ai what does the alerts_v2 table represent?
k
The
alerts_v2
table is Elementary's central alert tracking table, introduced in version 0.14.0 to replace the older
alerts_dbt_models
and related views. [alerts_dbt_models deprecated] Here's what it represents and how it works: What alerts_v2 Contains It stores all pending and sent alerts across all alert types — test failures/warnings, model errors, and source freshness issues. You can query it by type, e.g.:
Copy code
select * from <elementary_schema>.alerts_v2 where type = 'model'
Each row includes a
data
JSON column with rich alert context such as: •
id
,
alert_class_id
,
model_unique_id
,
test_unique_id
•
detected_at
,
database_name
,
schema_name
,
table_name
,
column_name
•
test_type
,
test_sub_type
,
test_results_description
•
owners
,
tags
,
test_rows_sample
,
severity
,
status
•
test_params
,
test_meta
,
model_meta
It also has a
sent_at
column to track when an alert was dispatched. [alerts_v2 structure] How It's Used in the Alerting Flow When
edr monitor
runs, it follows this sequence: [duplicate alerts explanation] 1. Populates
alerts_v2
from all artifacts the Elementary dbt package has collected (incrementally). 2. Filters the relevant alerts according to any
--filters
arguments you pass. 3. Sends the alerts to Slack (or other destinations). 4. Updates the rows in
alerts_v2
to mark them as sent (recording
sent_at
). Key Characteristics • It is an incremental table — rows are merged/inserted rather than the table being recreated on each run. [incremental model] • Alert rows have a status field (e.g.,
pending
,
skipped
,
sent
). A
skipped
status typically means the test was not executed or was suppressed. • Running multiple
edr monitor
commands simultaneously can cause duplicate rows, because both runs see the same "no alerts exist yet" state and both create them. The workaround is to run them sequentially. [duplicate alerts] 👍 0 button 👎 0 button ℹ️ Tip: Mention @elementary.ai in the thread for follow-ups or DM the app for 1-to-1 help.
a
@kapa.ai What is the difference between these 2 parameters and do I need to specify both? • Profile target: Choose a specific target in case you have multiple targets for Elementary.
Copy code
-t, --profile-target <target_name>
• Profile target of your dbt project: Choose a specific target in case you have multiple targets for your dbt project.
Copy code
--project-profile-target <target_name>
k
New message text here