Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions airflow_exporter/prometheus_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def get_dag_labels(dag_id: str) -> Dict[str, str]:


def get_metric_labels_from_tags(dag_id: str) -> Dict[str, str]:
known_tags = ('alert', 'schedule')
known_tags = ('alert', 'schedule', 'postcalc', 'product', 'env')

# reuse airflow webserver dagbag
dag = current_app.dag_bag.get_dag(dag_id)
Expand Down Expand Up @@ -417,10 +417,13 @@ def collect(self) -> Generator[Metric, None, None]:
dag_duration_metric = GaugeMetricFamily(
'airflow_dag_run_duration',
'Maximum duration of currently running dag_runs for each DAG in seconds',
labels=['dag_id']
labels=['dag_id', 'postcalc', 'env', 'product']
)
for dag_duration in get_dag_duration_info():
labels = get_dag_labels(dag_duration.dag_id)
labels = {
**get_dag_labels(dag_duration.dag_id),
**get_metric_labels_from_tags(dag_duration.dag_id)
}

_add_gauge_metric(
dag_duration_metric,
Expand Down
2 changes: 1 addition & 1 deletion tests/dags/slow_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
schedule_interval=timedelta(hours=5),
default_args=default_args,
catchup=False,
tags=["tag1", "alert:peak", "schedule:weekly"],
tags=["tag1", "alert:peak", "schedule:weekly", "postcalc:pc1", "env:dev", "product:toonblast"],
params={
'labels': {
'kind': 'slow'
Expand Down