How can I configure Airflow so that any failure in the DAG will (immediately) result in a slack message?
At this moment I manage it by creating a slack_failed_task:
slack_failed_task = SlackAPIPostOperator(
task_id='slack_failed',
channel="#datalabs",
trigger_rule='one_failed',
token="...",
text = ':red_circle: DAG Failed',
icon_url = 'http://airbnb.io/img/projects/airflow3.png',
dag=dag)
And set this task (one_failed) upstream from each other task in the DAG:
slack_failed_task << download_task_a
slack_failed_task << download_task_b
slack_failed_task << process_task_c
slack_failed_task << process_task_d
slack_failed_task << other_task_e
It works, but it's error prone since forgetting to add the task will skip the slack notifications and seems like a lot of work.
Is there perhaps a way to expand on the email_on_failure
property in the DAG?
Bonus ;-) for including a way to pass the name of the failed task to the message.
email_on_failure
property in the DAG?" - I do not know if you are still interested, but you may benefit from reading my post on how I have configured my airflow settings for emails on DAG failures using Amazon SES and theemail_on_failure
property. SO Post Here. Thanks! – Pontificalemail_on_failure
could be asink
to send messages to that then are either mailed or slacked or ... – Exasperate