Managing alert policies with the dagster-cloud CLI#
This guide is applicable to Dagster+.
In this guide, we'll walk you through managing Dagster+ alert policies using the dagster-cloud CLI. Alert policies apply to a full deployment (ex: prod), not Branch Deployments.
Don't want to work in code? You can also define and set alert policies using the Dagster+ UI.
Alert policies are defined in a YAML file and then, using the dagster-cloud CLI, set for a deployment. The YAML file should contain a single top-level key (alert_policies) and contain a list of alert policy objects. For example:
# alert_policies.yamlalert_policies:-name:"email-alert-policy"description:"An alert policy to email company executives during job failure."tags:-key:"level"value:"critical"event_types:-"JOB_FAILURE"notification_service:email:email_addresses:-"richard.hendricks@hooli.com"-"nelson.bighetti@hooli.com"
Only certain event_types can be specified together when using the CLI to create alerts. For example, multiple run-based event types can be included in the same policy, but attempting to include a tick event (such as TICK_FAILURE) will result in an error.
Organization, Admin, or Editor permissions in Dagster+, which are required to create and manage alerts
Optional: If using an integration like Microsoft Teams or Slack as a notification service, complete the integration setup before proceeding. Refer to the Supported notification services for a complete list of integrations.
First, define a list of alert policies in a YAML file. For example, the following policy listens for jobs with a tag of level: critical to fail:
# alert_policies.yamlalert_policies:-name:"email-alert-policy"description:"An alert policy to email company executives during job failure."tags:-key:"level"value:"critical"event_types:-"JOB_FAILURE"notification_service:email:email_addresses:-"richard.hendricks@hooli.com"-"nelson.bighetti@hooli.com"
Next, use the following command to set the policies for the deployment:
dagster-cloud deployment alert-policies sync -a /path/to/alert_policies.yaml