All Products
Search
Document Center

Data Management:Configure Airflow alert notifications

Last Updated:Aug 05, 2026

DMS Airflow supports alert notifications that notify you when a DAG succeeds or fails. You can use built-in DMS message notifications or configure a custom SMTP email service to send alert emails.

Prerequisites

You have set up an Airflow environment.

Use DMS message notification

  1. Go to the target code repository.

  2. Configure the dependency.

    from airflow.providers.alibabadms.cloud.notifications.dms_notification import DmsNotifier
  3. Configure alert notifications.

    By default, alert notifications are sent to the workspace administrator. You can change the recipients in Notification management.

    • Failure alert: In the DAG, add the on_failure_callback parameter and set its value to lambda context: DmsNotifier(success=False).notify(context).

    • Success alert: In the DAG, add the on_success_callback parameter and set its value to lambda context: DmsNotifier(success=True).notify(context).

    Sample code:

    dag = DAG(
    	dag_id='iac_ove_test',
    	on_failure_callback=lambda context: DmsNotifier(success=False).notify(context),
    	on_success_callback=lambda context: DmsNotifier(success=True).notify(context)
    )
    Note

    The preceding configuration sets alerts at the DAG level, so only one notification is sent per DAG run. To send a separate notification for each task, place on_failure_callback and on_success_callback in the DAG's default_args.

Use a custom email service

By configuring SMTP service parameters and an Airflow connection, you can use a custom email service to send Airflow alert notification emails. The configuration involves two steps:

  1. Set the SMTP service parameters in the Airflow instance configuration options.

  2. Create an smtp_default connection in Airflow to store the email authentication credentials.

Airflow can send alert emails only after both steps are completed.

Step 1: Configure SMTP service parameters

  1. Log in to DMS 5.0.

  2. Click the 2023-01-28_15-57-17.png icon in the upper-left corner of the console, and then choose All Features > Data+AI > Workspace.

    Note

    If you are using the non-compact console mode, choose Data+AI > Workspace from the top menu bar.

  3. Click the workspace name that contains the Airflow instance, and then choose image > Airflow Instance in the left-side navigation pane.

  4. In the Operation column of the target Airflow instance, click Configuration Options.

  5. In the dialog box that appears, click Add Configuration Option and add the following SMTP configuration options.

    Important

    smtp.smtp_ssl and smtp.smtp_starttls are mutually exclusive encryption methods and cannot be set to True at the same time.

    Configuration option

    Example value

    Description

    smtp.smtp_host

    smtp.qiye.aliyun.com

    The SMTP server address provided by your email service provider

    smtp.smtp_port

    465

    The SMTP service port. Typically 465 for SSL or 587 for STARTTLS

    smtp.smtp_ssl

    True

    Whether to enable SSL encryption. If enabled, set smtp.smtp_starttls to False

    smtp.smtp_starttls

    False

    Whether to enable STARTTLS encryption. If enabled, set smtp.smtp_ssl to False

    smtp.smtp_mail_from

    sender@example.com

    The sender email address for alert emails

    smtp.smtp_user

    sender@example.com

    The login account for SMTP server authentication, usually the same as the sender address

  6. Click Confirm.

    Wait for the configuration to take effect. The Airflow instance status changes to Deploying and then back to Running, which indicates that the configuration has taken effect.

Step 2: Configure the Airflow connection

After the SMTP service parameters are configured, configure an Airflow connection to store the email authentication credentials.

  1. In the Operation column of the target Airflow instance, click Open to access the Airflow Web UI.

  2. In the left-side navigation pane, choose Admin > Connections.

  3. Click Add Connection in the upper-right corner and configure the following parameters.

    Parameter

    Value

    Description

    Connection ID

    smtp_default

    Fixed value. Do not change this value. Airflow uses this ID by default to retrieve the SMTP authentication credentials.

    Connection Type

    SMTP

    Select SMTP

    Login

    Your email address

    Must be the same as the smtp.smtp_user configuration value

    Password

    Your email password

    The login password or app-specific password (authorization code) for the email account

  4. Click Save.

After the configuration is complete, you can use EmailOperator in a DAG or set email_on_failure = True to trigger alert emails and verify that the SMTP configuration works.