This appendix explains how Airflow’s StatsD metrics are translated into Prometheus-friendly metrics via the Prometheus StatsD exporter. The goal is to standardize metric names, attach meaningful labels, and ensure efficient, Prometheus-aligned exposition. Because Airflow evolves, the mapping is explicit yet subject to change, providing a clear bridge between the hierarchical StatsD naming style and Prometheus’s labeled, snake_case conventions.
The mapping covers several categories of DAG-level observability. It includes total DAG parsing time, the count of discovered DAGs, and the number of import errors during DAG processing. It also maps loading durations per file (with concatenated DAG IDs when multiple DAGs reside in one file) and captures recent processing characteristics, such as last duration, last runtime, and seconds since the last run, labeled by filename. At the DAG run level, it exposes dependency checks, successful run durations, and schedule delay per dag_id, enabling analysis of scheduling latency and runtime behavior across pipelines.
Task and execution-layer visibility is addressed through task duration metrics labeled by dag_id and task_id, along with executor capacity indicators: open slots, queued tasks, and running tasks. Pattern-based matching (with wildcards and capture groups) is used to extract label values from StatsD metric paths, producing concise Prometheus metric names and consistent labels. Together, these mappings offer a coherent, label-rich metric surface for dashboards and alerting across DAG parsing, scheduling, task execution, and executor resource utilization.
FAQ
What is the purpose of the Prometheus StatsD exporter mapping in Appendix B?The mapping translates Airflow’s StatsD metrics into Prometheus-friendly metric names and labels, aligning with Prometheus naming conventions and improving efficiency of metric exposition.How is this mapping used with the Prometheus StatsD exporter?You supply the mapping configuration to the Prometheus StatsD exporter. The exporter receives Airflow’s StatsD metrics and rewrites them to the specified Prometheus metric names and labels before exposing them for scraping.Where can I find the mapping associated with this appendix?The mapping is included in the book’s companion repository at https://github.com/godatadriven/data-pipelines-with-airflow-2nd-ed, where it is demonstrated with the Prometheus StatsD exporter.Why not rely on the exporter’s default conversions?Some automatic conversions are either inefficient or do not follow Prometheus naming best practices. The explicit mapping ensures consistent, meaningful names and label sets for Airflow metrics.Are these mappings stable over time?No. Because Airflow is an active open source project, metric names and structures can change, so this mapping may evolve.How are labels derived from the StatsD metric names?Wildcards in the match patterns capture parts of the metric name. These captured groups are referenced as $1, $2, etc., and are assigned to labels (for example, dag_id: "$1", task_id: "$2").How is task duration mapped from StatsD to Prometheus?The StatsD metric airflow.dag.*.*.duration is mapped to the Prometheus metric airflow_task_duration with labels dag_id = $1 and task_id = $2.Which mappings provide DAG inventory and error counts?airflow.dagbag_size maps to airflow_dag_count (number of DAGs). airflow.dag_processing.import_errors maps to airflow_dag_errors (count of DAG processing errors).Which mappings cover DAG file processing and loading timings?airflow.dag_processing.total_parse_time maps to airflow_dag_processing_time (total seconds to process all DAG files). airflow.dag.loading-duration.* maps to airflow_dag_loading_duration with label dag_ids = $1 (concatenated when multiple DAGs are in one file). The file-specific timings use filename labels: airflow.dag_processing.last_duration.* → airflow_dag_processing_last_duration (filename = $1), airflow.dag_processing.last_run.seconds_ago.* → airflow_dag_processing_last_run_seconds_ago (filename = $1), and airflow.dag_processing.last_runtime.* → airflow_dag_processing_last_runtime (filename = $1).What mappings exist for DAG run and executor metrics?airflow.dagrun.dependency-check.* → airflow_dag_processing_last_runtime (dag_id = $1). airflow.dagrun.duration.success.* → airflow_dagrun_success_duration (dag_id = $1). airflow.dagrun.schedule_delay.* → airflow_dagrun_schedule_delay (dag_id = $1). Executor capacity and workload: airflow.executor.open_slots → airflow_executor_open_slots; airflow.executor.queued_tasks → airflow_executor_queued_tasks; airflow.executor.running_tasks → airflow_executor_running_tasks.
pro $24.99 per month
access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!