Reputation: 21
I'm trying to implement a way to get notified when my dag fails.
I tried to use the email_on_failure and a webhook method ( https://code.mendhak.com/Airflow-MS-Teams-Operator/ ). But for both of them, I got a notification for every task that failed. Is there a way to get notified only if the whole dag doesn't work?
I really appreciate any help you can provide.
Upvotes: 2
Views: 7206
Reputation: 15911
You can choose to set on_failure_callback
on operator level or on DAG level.
On Dag - A function to be called when a DagRun of this dag fails.
On Operator - a function to be called when a task instance of this task fails.
In your case you need to set on_failure_callback
in your DAG object:
dag = DAG(
dag_id=dag_id,
on_failure_callback=func_to_execute,
)
Upvotes: 1