From 3c793f67bf1c97f51462b1879b7e6ac3e8ea0cb1 Mon Sep 17 00:00:00 2001 From: Frank Tubbing Date: Tue, 6 Feb 2024 08:37:51 +0100 Subject: [PATCH] Added documentation how to setup the Microsoft Teams alerting --- docs/_snippets/setup-teams-integration.mdx | 108 ++++++++++++++++++ .../deployment-and-configuration/teams.mdx | 22 ++++ docs/oss/guides/send-teams-alerts.mdx | 50 ++++++++ .../alerts/integrations/slack/slack.py | 3 +- 4 files changed, 181 insertions(+), 2 deletions(-) create mode 100644 docs/_snippets/setup-teams-integration.mdx create mode 100644 docs/oss/deployment-and-configuration/teams.mdx create mode 100644 docs/oss/guides/send-teams-alerts.mdx diff --git a/docs/_snippets/setup-teams-integration.mdx b/docs/_snippets/setup-teams-integration.mdx new file mode 100644 index 000000000..9780e3c97 --- /dev/null +++ b/docs/_snippets/setup-teams-integration.mdx @@ -0,0 +1,108 @@ +First create a Microsoft Teams team: + + + +## Create a new Team + +Go to the Microsoft Teams desktop app and create a new team. + +Microsoft Teams team + +Create a team from from a template and use the `From Scratch` template. + +Microsoft Teams template + +Choose `Public` as the kind of a team. + +Microsoft Teams public team + +Call it `Elementary` (or whatever you prefer) and connect it to the workspace of your choice. + +Microsoft Teams Elementary team + + + +Now it is time to setup the webhook for this channel. + + + +## Create a webhook + +Go to a channel in your Team and choose `Manage channel` + +Teams manage channel + +Choose `Edit` connectors. + +Teams edit connectors + +Search for `Incoming webhook` and choose `Add`. + +Teams add incoming webhook + +Choose `Add` again and add name your webhook `ElementaryWebhook` (or whatever you prefer). And `Create` the webhook. + +Teams create webhook + +Copy the URL of the webhook. + +Teams copy URL webhook + + + +Lastly, pass the webhook to the CLI as a param or in the `config.yml` file: + + + +## Webhook: + +Use the webhook URL when you execute edr monitor using the option `-tw, --teams-webhook`: + +```shell +edr monitor --teams-webhook +``` + + + + + +The CLI reads the Teams integration from a file, copy it into a file called config.yml. +Create it here: `HOME_DIR/.edr/config.yml` + +Here is the format in the yml itself: + +## Webhook: + +```yml config.yml +teams: + teams_webhook: +``` + + diff --git a/docs/oss/deployment-and-configuration/teams.mdx b/docs/oss/deployment-and-configuration/teams.mdx new file mode 100644 index 000000000..75ddf57fd --- /dev/null +++ b/docs/oss/deployment-and-configuration/teams.mdx @@ -0,0 +1,22 @@ +--- +title: "Teams setup for Elementary CLI" +sidebarTitle: "Teams" +--- + +Elementary Teams integration includes sending [Teams alerts](/oss/guides/send-teams-alerts) on failures in dbt tests and models. + +## Integration options + +There is one integration option for Microsoft Teams: a Webhook. This method let you receive alerts from Elementary, but lacks +some support that is available in the Slack integration solution. +Below is features support comparison table (with Slack), to help you select the integration method. + +| Integration | Elementary alerts | Elementary report | Multiple channels | Slack workflows | +| ------------- | ----------------- | ----------------- | ----------------- | --------------- | +| Teams Webhook | ✅ | ❌ | ❌ | ❌ | +| Slack Token | ✅ | ✅ | ✅ | ❌ | +| Slack Webhook | ✅ | ❌ | ❌ | ✅ | + +## Teams integration setup + + diff --git a/docs/oss/guides/send-teams-alerts.mdx b/docs/oss/guides/send-teams-alerts.mdx new file mode 100644 index 000000000..3c2d05728 --- /dev/null +++ b/docs/oss/guides/send-teams-alerts.mdx @@ -0,0 +1,50 @@ +--- +title: "Setup Teams alerts" +--- + + + +## Setup Teams Integration + + + +**Before you start** + +Before you can start using the alerts, make sure to [install the dbt package](/oss/quickstart/quickstart-cli-package), [configure a profile and install the CLI](/oss/quickstart/quickstart-cli). +This is **required for the alerts to work.** + +
+
+ + + +## Execute the CLI + +Make sure to run the following command after your dbt runs and tests: + +``` +edr monitor --teams-webhook --group-by [table | alert] +``` + +Or just `edr monitor` if you used `config.yml`. + +--- + +## Alert on source freshness failures + +_Not supported in dbt cloud_ + +To alert on source freshness, you will need to run `edr run-operation upload-source-freshness` right after each execution of `dbt source freshness`. +This operation will upload the results to a table, and the execution of `edr monitor` will send the actual alert. + +- Note that `dbt source freshness` and `upload-source-freshness` needs to run from the same machine. +- Note that `upload-source-freshness` requires passing `--project-dir` argument. + +## Continuous alerting + +In order to monitor continuously, use your orchestrator to execute it regularly (we recommend running it right after +your dbt job ends to monitor the latest data updates). + +Read more about how to deploy [Elementary in production](/oss/deployment-and-configuration/elementary-in-production). +If you need help or wish to consult on this, reach out to us +on [Slack](https://elementary-data.com/community). diff --git a/elementary/monitor/data_monitoring/alerts/integrations/slack/slack.py b/elementary/monitor/data_monitoring/alerts/integrations/slack/slack.py index a05ee8e37..7dd24e1a8 100644 --- a/elementary/monitor/data_monitoring/alerts/integrations/slack/slack.py +++ b/elementary/monitor/data_monitoring/alerts/integrations/slack/slack.py @@ -29,11 +29,10 @@ list_of_lists_of_strings_to_comma_delimited_unique_strings, ) from elementary.utils.log import get_logger +from elementary.utils.strings import prettify_and_dedup_list logger = get_logger(__name__) -from elementary.utils.strings import prettify_and_dedup_list - TABLE_FIELD = "table" COLUMN_FIELD = "column" DESCRIPTION_FIELD = "description"