Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion docs/_snippets/guides/alerts-code-configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ tests:

#### Test description

Elementary supports configuring description for tests that are included in alerts.
Elementary supports configuring description for tests and source freshness checks 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>
Expand Down Expand Up @@ -170,6 +170,15 @@ tests:
description: "This is the test description"
```

```yml source
sources:
- name: my_source
tables:
- name: my_table
meta:
description: "This is the source freshness description"
```

</CodeGroup>

#### Tags
Expand Down
2 changes: 1 addition & 1 deletion elementary/monitor/fetchers/alerts/schema/alert_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def format_alert(
max_loaded_at=self.max_loaded_at,
max_loaded_at_time_ago_in_s=self.max_loaded_at_time_ago_in_s,
filter=self.filter,
freshness_description=self.freshness_description,
freshness_description=self.description or self.freshness_description,
alert_class_id=self.alert_class_id,
model_unique_id=self.model_unique_id,
detected_at=self.detected_at,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from elementary.monitor.fetchers.alerts.schema.alert_data import (
BaseAlertDataSchema,
SourceFreshnessAlertDataSchema,
TestAlertDataSchema,
)
from elementary.utils.time import DATETIME_FORMAT
Expand Down Expand Up @@ -37,6 +38,15 @@
test_meta=dict(),
elementary_unique_id="e_id_1"
)
SOURCE_FRESHNESS_ALERT = dict(
**BASE_ALERT,
source_freshness_execution_id="sfe_id_1",
source_name="source_1",
identifier="table_1",
original_status="error",
path="models/sources.yml",
freshness_description="default"
)


def test_flatten_meta():
Expand Down Expand Up @@ -119,3 +129,18 @@ def test_tags():

base_alert = BaseAlertDataSchema(**{**BASE_ALERT, "tags": "a"})
assert sorted(base_alert.tags) == sorted(["a"])


@pytest.mark.parametrize(
"model_meta,expected",
[
(dict(), "default"),
(dict(description="custom"), "custom"),
(dict(alerts_config=dict(description="custom")), "custom"),
],
)
def test_source_freshness_alert_description(model_meta, expected):
alert_data = SourceFreshnessAlertDataSchema(
**{**SOURCE_FRESHNESS_ALERT, "model_meta": model_meta}
)
assert alert_data.format_alert().freshness_description == expected
Loading