Skip to content

Conversation

@AutomationDev85
Copy link
Contributor

Overview

While working with deferred tasks, we found that the airflow_ti_running metric does not include task instances in the deferred state. This change extends metric export to also cover scheduled, queued, and deferred states. With these metrics you can build dashboards that show per-DAG load in running and deferred states, and monitor how many tasks per DAG are waiting for resources in scheduled and queued states.

Change Summary

  • Add ti.scheduled, ti.queued and ti.deferred metrics to the code which exports the ti.running

  • Update description with new metrics.

  • Add fix for task_id to replace . because task group tasks are breaking the stasd exporting because of using . separator.

  • Add ti.scheduled, ti.queued and ti.deferred metrics alongside ti.running.

  • Update metric descriptions to reflect the new states.

  • Replace . with __ in task_id for StatsD compatibility (task groups use . as a separator, which breaks StatsD’s dot-delimited metric hierarchy).

Copy link
Contributor

@jscheffl jscheffl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general this all makes sense. But the configuration can not be "just" renamed as well as some mypy static fails. I assume you know how to fix.

@AutomationDev85 AutomationDev85 force-pushed the feature/task-instance-metric-add-more-states branch 2 times, most recently from b09efdf to 928210a Compare December 1, 2025 13:54
@jscheffl jscheffl added this to the Airflow 3.1.4 milestone Dec 2, 2025
@AutomationDev85 AutomationDev85 force-pushed the feature/task-instance-metric-add-more-states branch from 5f73cee to 62d61ac Compare December 4, 2025 13:08
@jscheffl jscheffl modified the milestones: Airflow 3.1.4, Airflow 3.2.0 Dec 7, 2025
@jscheffl jscheffl force-pushed the feature/task-instance-metric-add-more-states branch from 62d61ac to 877752b Compare December 7, 2025 18:07
Copy link
Contributor

@jscheffl jscheffl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good for me, some other pair of eyes might be good, otherwise LGTM. Will elave it open for a moment for others to review prior merge.

@jscheffl jscheffl merged commit 92fd810 into apache:main Dec 14, 2025
164 of 165 checks passed
TempestShaw pushed a commit to TempestShaw/airflow that referenced this pull request Dec 24, 2025
…pache#58819)

* ti metric export of scheduled, queued and deferred

* Added deprecated warning for new option

* only add task_id to metric

---------

Co-authored-by: AutomationDev85 <AutomationDev85>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ConfigTemplates area:helm-chart Airflow Helm Chart area:Scheduler including HA (high availability) scheduler kind:documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants