When Airflow runs in production, metrics can reveal failing tasks, slow DAG parsing, and pressure on the systems it depends on. Prometheus stores monitoring metrics as time series and retrieves them by periodically scraping configured targets. Grafana can then query Prometheus to display those metrics in dashboards. section 15.7.3 section 15.7.4 section 15.7.5
Airflow’s StatsD client pushes metrics, but Prometheus pulls metrics and cannot scrape Airflow directly in Prometheus format. Put the Prometheus StatsD exporter between them: Airflow pushes StatsD metrics to the exporter, which translates and exposes them for Prometheus to scrape. section 15.7.1 section 15.7.3
Figure 15.10 Software and steps required for collecting and visualizing metrics from Airflow. Prometheus collects metrics, and Grafana visualizes metrics in dashboards. The Prometheus StatsD exporter translates StatsD metrics to Prometheus’s metrics format and exposes them for Prometheus to scrape.
Follow the path from Airflow through the StatsD exporter and Prometheus to the Grafana dashboard. section 15.7.1
A minimal setup has three checks:
- Run the StatsD exporter with Docker, exposing port 9125/udp for incoming StatsD metrics and port 9102 for scraping. Match the incoming port to AIRFLOW__SCHEDULER__STATSD_PORT, then inspect http://localhost:9102/metrics. section 15.7.3
- Configure a Prometheus scrape job named airflow with the exporter as its target, then run Prometheus. Check http://localhost:9090/targets: an UP target confirms that scraping is working. section 15.7.3
- Add Prometheus at http://localhost:9090 as a Grafana data source. Plot airflow_dag_processing_total_parse_time to watch how long processing all DAGs takes; a large spike may indicate a scheduler or DAG-file problem. section 15.7.4
Select a task metric
Prometheus identifies a metric by its name and key-value labels. A query such as task_duration{task_id="first_task"} selects that metric for one task ID rather than every task. section 15.7.3
Monitoring need not stop at Airflow metrics. Prometheus exporters can expose machine, metastore, Celery, Redis, endpoint, and Kubernetes metrics where relevant. Expect some dashboard delay: Prometheus scrapes at intervals, and Grafana queries it separately. This setup monitors metrics rather than recording individual events or configuring alerts. section 15.7.5 section 15.7.4







