Skip to main content
Version: 0.18.9

Trigger Slack notifications as an Action

This guide will help you trigger Slack notifications as an ActionA Python class with a run method that takes a Validation Result and does something with it. It will allow you to send a Slack message including information about a Validation ResultGenerated when data is Validated against an Expectation or Expectation Suite., including whether or not the ValidationThe act of applying an Expectation Suite to a Batch. succeeded.

Great Expectations is able to use a Slack webhook or Slack app to send notifications.

Prerequisites

Edit your configuration variables to include the Slack webhook

Open uncommitted/config_variables.yml file and add validation_notification_slack_webhook variable by adding the following line:

YAML
validation_notification_slack_webhook: [address to web hook]

Include the send_slack_notification_on_validation_result Action in your Checkpoint configuration

Open the .yml configuration file in great_expectations/checkpoints that corresponds to the CheckpointThe primary means for validating data in a production deployment of Great Expectations. you want to add Slack notifications to.

Add the send_slack_notification_on_validation_result Action to the action_list section of the configuration. Make sure the following section exists in the Checkpoint configuration.

Webhook config

YAML
action_list:
#--------------------------------
# here is what you will be adding
#--------------------------------
- name: send_slack_notification_on_validation_result # name can be set to any value
action:
class_name: SlackNotificationAction
# put the actual webhook URL in the uncommitted/config_variables.yml file
slack_webhook: ${validation_notification_slack_webhook}
notify_on: all # possible values: "all", "failure", "success"
notify_with: # optional list containing the DataDocs sites to include in the notification. Defaults to including links to all configured sites.
renderer:
module_name: great_expectations.render.renderer.slack_renderer
class_name: SlackRenderer

Test your Slack notifications

Run your Checkpoint to Validate a BatchA selection of records from a Data Asset. of data and receive Slack notification on the success or failure of the Expectation Suite'sA collection of verifiable assertions about data. Validation. See Run your Checkpoint.

If successful, you should receive a Slack message that looks like this:

slack_notification_example

Additional notes

  • If your great_expectations.yml contains multiple configurations for Data DocsHuman readable documentation generated from Great Expectations metadata detailing Expectations, Validation Results, etc. sites, all of them will be included in the Slack notification by default. If you would like to be more specific, you can configure the notify_with variable in your Checkpoint configuration.
  • The following example will configure the Slack message to include links Data Docs at local_site and s3_site.
YAML
    # Example data_docs_sites configuration
data_docs_sites:
local_site:
class_name: SiteBuilder
show_how_to_buttons: true
store_backend:
class_name: TupleFilesystemStoreBackend
base_directory: uncommitted/data_docs/local_site/
site_index_builder:
class_name: DefaultSiteIndexBuilder
s3_site: # this is a user-selected name - you may select your own
class_name: SiteBuilder
store_backend:
class_name: TupleS3StoreBackend
bucket: data-docs.my_org # UPDATE the bucket name here to match the bucket you configured above.
site_index_builder:
class_name: DefaultSiteIndexBuilder
show_cta_footer: true
YAML
    # Example action_list in Checkpoint configuration   
action_list:
- name: send_slack_notification_on_validation_result # name can be set to any value
action:
class_name: SlackNotificationAction
# put the actual webhook URL in the uncommitted/config_variables.yml file
slack_webhook: ${validation_notification_slack_webhook}
notify_on: all # possible values: "all", "failure", "success"
#--------------------------------
# This is what was configured
#--------------------------------
notify_with:
- local_site
- s3_site
renderer:
module_name: great_expectations.render.renderer.slack_renderer
class_name: SlackRenderer