Airflow: Send email notification on DAG success

Created on 9 Nov 2020  路  2Comments  路  Source: apache/airflow

Description

Airflow currently sends notifications on DAG failures. This feature request is to apply the same behavior to DAG successes as well, as an option. The default could be set to False.

Use case / motivation

To ensure that the DAGs run as scheduled.

Related Issues

invalid feature

Most helpful comment

Users can use custom on_success_callback to achieve this behaviour:

from airflow.utils.email import send_email

def on_success_callback(context):
    ti: TaskInstance = context["ti"]
    dag_id = ti.dag_id
    task_id = ti.task_id

    msg = "DAG succeeded"
    subject = f"Success {dag_id}.{task_id}"
    send_email(to=EMAIL_LIST, subject=subject, html_content=msg)

Personally I prefer this generic approach - users can customise the subject, title and what ever they want to fit their needs.

All 2 comments

Thanks for opening your first issue here! Be sure to follow the issue template!

Users can use custom on_success_callback to achieve this behaviour:

from airflow.utils.email import send_email

def on_success_callback(context):
    ti: TaskInstance = context["ti"]
    dag_id = ti.dag_id
    task_id = ti.task_id

    msg = "DAG succeeded"
    subject = f"Success {dag_id}.{task_id}"
    send_email(to=EMAIL_LIST, subject=subject, html_content=msg)

Personally I prefer this generic approach - users can customise the subject, title and what ever they want to fit their needs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

turbaszek picture turbaszek  路  3Comments

mik-laj picture mik-laj  路  3Comments

grbinho picture grbinho  路  3Comments

jaketf picture jaketf  路  3Comments

Labbs picture Labbs  路  4Comments