Airflow is a widely-used workflow automation and scheduling platform that can be used to author and manage data pipelines. Airflow uses workflows made of directed acyclic graphs (DAGs) of tasks. To learn more about Airflow, check out the Airflow documentation.
How does Airflow work with OpenLineage?
Understanding complex inter-DAG dependencies and providing up-to-date runtime visibility into DAG execution can be challenging. OpenLineage integrates with Airflow to collect DAG lineage metadata so that inter-DAG dependencies are easily maintained and viewable via a lineage graph, while also keeping a catalog of historical runs of DAGs.
The DAG metadata collected can answer questions like:
- Why has a DAG failed?
- Why has the DAG runtime increased after a code change?
- What are the upstream dependencies of a DAG?
How can I use this integration?
To use the OpenLineage Airflow integration, you'll need a running Airflow instance. You'll also need an OpenLineage compatible backend.
To download and install the latest
openlineage-airflow library, update the
requirements.txt file of your running Airflow instance with:
Next, we'll need to specify where we want OpenLineage to send events. There are a few options.
Simplest one is to use
OPENLINEAGE_URL environment variable.
For example, to send OpenLineage events to a local instance of Marquez, use:
To set up additional configuration, or send events to other targets than HTTP server (like Kafka topic) take a look at client configuration.
If you use older version of Airflow than 2.3.0, additional configuration is required.
The following environment variables are available specifically for Airflow integration.
|OPENLINEAGE_AIRFLOW_DISABLE_SOURCE_CODE||Set to |
|OPENLINEAGE_EXTRACTORS||The optional list of extractors class in case you need to use custom extractors.|
|OPENLINEAGE_NAMESPACE||The optional namespace that the lineage data belongs to. If not specified, defaults to |
When enabled, the integration will:
- On TaskInstance start, collect metadata for each task
- Collect task input / output metadata (source, schema, etc)
- Collect task run-level metadata (execution time, state, parameters, etc)
- On TaskInstance complete, also mark the task as complete in Marquez
Where can I learn more?
- Take a look at Marquez's Airflow example to learn how to enable OpenLineage metadata collection for Airflow DAGs and troubleshoot failing DAGs using Marquez.
- Watch Data Lineage with OpenLineage and Airflow
You can reach out to us on slack and leave us feedback!