Reputation: 1726
I am setting up a DAG which initiates with a sensor. The sensor checks to see if some files have been loaded that morning. If the files haven't loaded by 12pm that day, I want to schedule an email instead. What is the best way to approach this and can you create a time dependent ifelse logic?
Upvotes: 1
Views: 1788
Reputation: 985
You need to implement SLA: https://airflow.apache.org/docs/apache-airflow/stable/concepts.html#slas
Service Level Agreements, or time by which a task or DAG should have succeeded, can be set at a task level as a timedelta. If one or many instances have not succeeded by that time, an alert email is sent detailing the list of tasks that missed their SLA. The event is also recorded in the database and made available in the web UI under Browse->SLA Misses where events can be analyzed and documented.
SLAs can be configured for scheduled tasks by using the sla parameter. In addition to sending alerts to the addresses specified in a task’s email parameter, the sla_miss_callback specifies an additional Callable object to be invoked when the SLA is not met.
A complete Airflow SLA tutorial: https://blog.clairvoyantsoft.com/airflow-service-level-agreement-sla-2f3c91cd84cc
Upvotes: 1