Airflow failed slack message

前端 未结 4 954

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:<

4条回答
  •  粉色の甜心
    2021-01-03 11:16

    The BaseOperator supports 'on_failure_callback' parameter:

    on_failure_callback (callable) – a function to be called when a task instance of this task fails. a context dictionary is passed as a single parameter to this function. Context contains references to related objects to the task instance and is documented under the macros section of the API.

    I have not tested this but you should be able to define a function which posts to slack on failure and pass it to each task definition. To get the name of the current task, you can use the {{ task_id }} template.

提交回复
热议问题