This is an automated email from the ASF dual-hosted git repository.
Miretpl pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 50a34bff69f Add TTL to fix stale ti metrics (#76540)
50a34bff69f is described below
commit 50a34bff69f09f321f4f6bb1c3ea72a505d204cb
Author: AutomationDev85 <[email protected]>
AuthorDate: Mon Nov 30 18:30:06 2026 +0100
Add TTL to fix stale ti metrics (#76540)
Co-authored-by: AutomationDev85 <AutomationDev85>
---
chart/files/statsd-mappings.yml | 4 ++++
chart/tests/helm_tests/other/test_statsd.py | 23 +++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/chart/files/statsd-mappings.yml b/chart/files/statsd-mappings.yml
index a6a216e9c32..522d4e57b95 100644
--- a/chart/files/statsd-mappings.yml
+++ b/chart/files/statsd-mappings.yml
@@ -115,6 +115,7 @@ mappings:
- match: airflow.ti.running.*.*.*
name: "airflow_ti_running"
+ ttl: 5m
labels:
queue: "$1"
dag_id: "$2"
@@ -122,6 +123,7 @@ mappings:
- match: airflow.ti.queued.*.*.*
name: "airflow_ti_queued"
+ ttl: 5m
labels:
queue: "$1"
dag_id: "$2"
@@ -129,6 +131,7 @@ mappings:
- match: airflow.ti.scheduled.*.*.*
name: "airflow_ti_scheduled"
+ ttl: 5m
labels:
queue: "$1"
dag_id: "$2"
@@ -136,6 +139,7 @@ mappings:
- match: airflow.ti.deferred.*.*.*
name: "airflow_ti_deferred"
+ ttl: 5m
labels:
queue: "$1"
dag_id: "$2"
diff --git a/chart/tests/helm_tests/other/test_statsd.py
b/chart/tests/helm_tests/other/test_statsd.py
index da6d6d5a332..04515b3209b 100644
--- a/chart/tests/helm_tests/other/test_statsd.py
+++ b/chart/tests/helm_tests/other/test_statsd.py
@@ -285,6 +285,29 @@ class TestStatsd:
assert "airflow_dagrun_dependency_check" in names
assert "airflow_pool_starving_tasks" in names
+ @pytest.mark.parametrize("default_ttl", ["0s", "10m"])
+ def test_statsd_state_gauge_mappings_expire(self, default_ttl):
+ docs = render_chart(
+ values={"statsd": {"cache": {"ttl": default_ttl}}},
+ show_only=["templates/configmaps/statsd-configmap.yaml"],
+ )
+ config = yaml.safe_load(docs[0]["data"]["mappings.yml"])
+ mappings = config["mappings"]
+ expected = [
+ {
+ "match": f"airflow.ti.{state}.*.*.*",
+ "name": f"airflow_ti_{state}",
+ "ttl": "5m",
+ "labels": {"queue": "$1", "dag_id": "$2", "task_id": "$3"},
+ }
+ for state in ("running", "queued", "scheduled", "deferred")
+ ]
+
+ assert [mapping for mapping in mappings if "ttl" in mapping] ==
expected
+ for mapping in expected:
+ assert sum(candidate["match"] == mapping["match"] for candidate in
mappings) == 1
+ assert config["defaults"]["ttl"] == default_ttl
+
def test_statsd_configmap_when_exist_extra_mappings(self):
extra_mapping = {
"match": "airflow.pool.queued_slots.*",