Is it possible to 'tag' an airflow DAG in the UI?

Viewed 3654

In the airflow DAG UI, I'd like to add a tag for a subset of DAGs. Let's say there is a tag #weekend_runs that I'd like to add to some specific DAGs.

Is it possible to filter your view of DAGs in the UI based on tags in Airflow? Or do I need to do something hacky like add _weekend_run to the end of DAG names in order to use fuzzy search and filter out other scripts?

Thanks!

2 Answers

Adding a tag to a DAG is now possible from Airflow 1.10.9

In order to filter DAGs (e.g by team), you can add tags in each dag. The filter is saved in a cookie and can be reset by the reset button.

For example:

Dag File:

dag = DAG('dag', tags=['example'])

UI: Dag Tag

Note: This feature is only available for the RBAC UI (enabled using rbac=True in [webserver] section in your airflow.cfg).

This is not possible yet and it's not even in the roadmap for Airflow 2.0. A hack I used in the past is to abuse of one of the fields (DAG name or Owner), as you suggested, for example by adding _weekend_run to the DAG name. And then I created a Greasemonkey userscript that allows to filter out the DAGs you don't want to show in the UI. Something along the line of the following script will do the job for your application:

// ==UserScript==
// @name         Only weekend runs
// @match        http://<airflow-instance-url-here>/admin/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    $('td:not:contains("weekend_run")').parent().hide();
})();

Unfortunately for this to work it needs to be installed on each user's browser, which is far from ideal. Of course, the ideal thing would be to make a PR to the Airflow project :)

Related