You can write listeners to enable Airflow to notify you when events happen. Pluggy powers these listeners.
Airflow supports notifications for the following events:
Lifecycle events allow you to react to start and stop events for an Airflow
DagRun State Change Events¶
DagRun state change events occur when a
DagRun changes state.
TaskInstance State Change Events¶
TaskInstance state change events occur when a
TaskInstance changes state.
You can use these events to react to
LocalTaskJob state changes.
Dataset events occur when Dataset management operations are run.
To create a listener:
hookimplsfor events that you’d like to generate notifications
Airflow defines the specification as hookspec. Your implementation must accept the same named parameters as defined in hookspec. If you don’t use the same parameters as hookspec, Pluggy throws an error when you try to use your plugin. But you don’t need to implement every method. Many listeners only implement one method, or a subset of methods.
To include the listener in your Airflow installation, include it as a part of an Airflow Plugin
Listener API is meant to be called across all DAGs and all operators. You can’t listen to events generated by specific DAGs. For that behavior, try methods like
pre_execute. These provide callbacks for particular DAG authors or operator creators. The logs and
print() calls will be handled as part of the listeners.
This is an experimental feature.