Configuration Reference¶
This page contains the list of all available Airflow configurations for the
apache-airflow-providers-apache-kafka provider that can be set in the airflow.cfg file or using environment variables.
Note
For more information see Setting Configuration Options.
[kafka_event_producer]¶
Settings for the Kafka event producer plugin that publishes Airflow DagRun and TaskInstance state-change events to a Kafka topic.
dag_run_dag_id_allowlist¶
Added in version 1.14.1.
Comma-separated glob patterns. When set, DagRun events are only emitted for dag_ids matching at least one pattern. Empty = all dags.
- Type:
string
- Default:
''- Environment Variable:
AIRFLOW__KAFKA_EVENT_PRODUCER__DAG_RUN_DAG_ID_ALLOWLIST- Example:
demo_*,test_dag1
dag_run_dag_id_denylist¶
Added in version 1.14.1.
Comma-separated glob patterns. DagRun events for dag_ids matching any pattern are skipped. Deny takes precedence over allow.
- Type:
string
- Default:
''- Environment Variable:
AIRFLOW__KAFKA_EVENT_PRODUCER__DAG_RUN_DAG_ID_DENYLIST- Example:
demo_*
dag_run_events_enabled¶
Added in version 1.14.1.
Publish DagRun state-change events (dag_run.running,
dag_run.success, dag_run.failed). When False the
DagRun listener is not registered.
- Type:
boolean
- Default:
False- Environment Variable:
AIRFLOW__KAFKA_EVENT_PRODUCER__DAG_RUN_EVENTS_ENABLED
kafka_config_id¶
Added in version 1.14.1.
Airflow connection used to build the plugin’s Kafka producer.
When unset, the producer hook falls back to its default
connection (kafka_default).
- Type:
string
- Default:
''- Environment Variable:
AIRFLOW__KAFKA_EVENT_PRODUCER__KAFKA_CONFIG_ID- Example:
kafka_default
source¶
Added in version 1.14.1.
Identifier added to every emitted message under the source
field so consumers can distinguish Airflow installations that
share the same topic. When unset, falls back to the hostname
of the Airflow component that emits the event (scheduler,
worker, etc.).
- Type:
string
- Default:
''- Environment Variable:
AIRFLOW__KAFKA_EVENT_PRODUCER__SOURCE- Example:
af-prod-eu
task_instance_dag_id_allowlist¶
Added in version 1.14.1.
Comma-separated glob patterns. When set, TaskInstance events are only emitted for dag_ids matching at least one pattern. Empty = all dags.
- Type:
string
- Default:
''- Environment Variable:
AIRFLOW__KAFKA_EVENT_PRODUCER__TASK_INSTANCE_DAG_ID_ALLOWLIST- Example:
demo_*,test_dag1
task_instance_dag_id_denylist¶
Added in version 1.14.1.
Comma-separated glob patterns. TaskInstance events for dag_ids matching any pattern are skipped. Deny takes precedence over allow.
- Type:
string
- Default:
''- Environment Variable:
AIRFLOW__KAFKA_EVENT_PRODUCER__TASK_INSTANCE_DAG_ID_DENYLIST- Example:
demo_*
task_instance_events_enabled¶
Added in version 1.14.1.
Publish TaskInstance state-change events (task_instance.running,
task_instance.success, task_instance.failed,
task_instance.skipped). When False the TaskInstance listener
is not registered.
- Type:
boolean
- Default:
False- Environment Variable:
AIRFLOW__KAFKA_EVENT_PRODUCER__TASK_INSTANCE_EVENTS_ENABLED
task_instance_task_id_allowlist¶
Added in version 1.14.1.
Comma-separated glob patterns. When set, TaskInstance events are
only emitted for task_ids matching at least one pattern. Applied
in addition to task_instance_dag_id_allowlist — both must pass.
Mapped task instances share the same task_id so a single pattern
covers all map indices.
- Type:
string
- Default:
''- Environment Variable:
AIRFLOW__KAFKA_EVENT_PRODUCER__TASK_INSTANCE_TASK_ID_ALLOWLIST- Example:
load_*,extract_*
task_instance_task_id_denylist¶
Added in version 1.14.1.
Comma-separated glob patterns. TaskInstance events for task_ids matching any pattern are skipped. Deny takes precedence over allow.
- Type:
string
- Default:
''- Environment Variable:
AIRFLOW__KAFKA_EVENT_PRODUCER__TASK_INSTANCE_TASK_ID_DENYLIST- Example:
*_cleanup
topic¶
Added in version 1.14.1.
Topic the plugin publishes events to. The topic must already exist on the broker; the plugin will not auto-create it.
- Type:
string
- Default:
airflow.events- Environment Variable:
AIRFLOW__KAFKA_EVENT_PRODUCER__TOPIC
topic_check_retry_interval¶
Added in version 1.14.1.
How long (in seconds) to wait before retrying a topic check, in case it failed.
- Type:
integer
- Default:
60- Environment Variable:
AIRFLOW__KAFKA_EVENT_PRODUCER__TOPIC_CHECK_RETRY_INTERVAL
topic_check_timeout¶
Added in version 1.14.1.
How long (in seconds) each topic existence check is allowed to block waiting for a response from the broker.
- Type:
integer
- Default:
10- Environment Variable:
AIRFLOW__KAFKA_EVENT_PRODUCER__TOPIC_CHECK_TIMEOUT
Highlighted configurations¶
The [kafka_event_producer] section configures the KafkaEventProducerPlugin,
which publishes Airflow DagRun and TaskInstance state-change events to a
Kafka topic. DagRun and TaskInstance events are separated and enabled by
distinct flags. Both event-type flags default to False.
Common use-cases¶
Consume the Kafka events by an external observability or analytics tool and gather info about the state of multiple Airflow instances without polling their metadata DBs.
Based on the state of a DagRun, trigger a downstream external system/pipeline (notifications, alerting, cross-team handoffs) without direct interaction with Airflow.
Coordinate Dags across multiple Airflow instances over a shared Kafka service.
For example, team_A with Airflow instance_A has a deferred task which is triggered when a task from team_B with Airflow instance_B finishes.
Activating the plugin¶
To enable event publishing you need to
enable at least one event-type flag
point the plugin at an Airflow Kafka connection via
kafka_config_id(defaults tokafka_default) that carries the broker address and any other confluent-kafka client options on its extrashave a pre-existing kafka topic
[kafka_event_producer]
dag_run_events_enabled = True
task_instance_events_enabled = True
kafka_config_id = kafka_events
topic = airflow.events
The connection’s extra JSON accepts the full confluent-kafka client
configuration — including SASL/TLS options and callbacks (e.g. error_cb,
oauth_cb) given as dotted-path strings, which are resolved to callables
before the producer is built.
{
"bootstrap.servers": "broker:9092",
"security.protocol": "SASL_SSL",
"sasl.mechanisms": "OAUTHBEARER",
"oauth_cb": "my_company.auth.oauth_cb"
}
Environment-variable equivalents:
AIRFLOW__KAFKA_EVENT_PRODUCER__DAG_RUN_EVENTS_ENABLED=True
AIRFLOW__KAFKA_EVENT_PRODUCER__TASK_INSTANCE_EVENTS_ENABLED=True
AIRFLOW__KAFKA_EVENT_PRODUCER__KAFKA_CONFIG_ID=kafka_events
AIRFLOW__KAFKA_EVENT_PRODUCER__TOPIC=airflow.events
The two event flags are independent, users can opt-in to get only DagRun event messages or only TaskInstance event messages or both.
The topic must already exist on the broker, it’s not auto-created. On a missing
topic, broker connection failure, or any other producer init error, the plugin
doesn’t fail, instead it logs a warning and retries the init after topic_check_retry_interval
seconds (default 60). Once the topic is created on the broker the plugin will pick it up.
Filtering events¶
DagRun and TaskInstance events are filtered separately. Each filter is a
comma-separated list of fnmatch glob patterns; an empty list means
“allow all”, and deny takes precedence over allow.
[kafka_event_producer]
dag_run_dag_id_allowlist = sales_*,marketing_*
dag_run_dag_id_denylist = sales_internal_*
task_instance_dag_id_allowlist = sales_*
task_instance_dag_id_denylist =
task_instance_task_id_allowlist = load_*,extract_*
task_instance_task_id_denylist = *_cleanup
TaskInstance events must pass both the dag-id and task-id filters.
Mapped task instances share their parent’s task_id, so a single
task_id pattern covers every map index.