Customizing the UI

Customizing state colours

New in version 1.10.11.

To change the colors for TaskInstance/DagRun State in the Airflow Webserver, perform the following steps:

  1. Create airflow_local_settings.py file and put in on $PYTHONPATH or to $AIRFLOW_HOME/config folder. (Airflow adds $AIRFLOW_HOME/config on PYTHONPATH when Airflow is initialized)

  2. Add the following contents to airflow_local_settings.py file. Change the colors to whatever you would like.

    1. STATE_COLORS = {
    2. "deferred": "mediumpurple",
    3. "failed": "firebrick",
    4. "queued": "darkgray",
    5. "removed": "lightgrey",
    6. "restarting": "violet",
    7. "running": "#01FF70",
    8. "scheduled": "tan",
    9. "shutdown": "blue",
    10. "skipped": "darkorchid",
    11. "success": "#2ECC40",
    12. "up_for_reschedule": "turquoise",
    13. "up_for_retry": "yellow",
    14. "upstream_failed": "orange",
    15. }
  3. Restart Airflow Webserver.

Screenshots

Before

../_images/dags-page-old.png ../_images/graph-view-old.png ../_images/tree-view-old.png

After

../_images/dags-page-new.png ../_images/graph-view-new.png ../_images/tree-view-new.png

Note

See Modules Management for details on how Python and Airflow manage modules.

Customizing DAG UI Header and Airflow Page Titles

Airflow now allows you to customize the DAG home page header and page title. This will help distinguish between various installations of Airflow or simply amend the page text.

Note

The custom title will be applied to both the page header and the page title.

To make this change, simply:

  1. Add the configuration option of instance_name under the [webserver] section inside airflow.cfg:
  1. [webserver]
  2. instance_name = "DevEnv"
  1. Alternatively, you can set a custom title using the environment variable:
  1. AIRFLOW__WEBSERVER__INSTANCE_NAME = "DevEnv"

Screenshots

Before

../_images/default_instance_name_configuration.png

After

../_images/example_instance_name_configuration.png

Note

From version 2.3.0 you can include markup in instance_name variable for further customization. To enable, set instance_name_has_markup under the [webserver] section inside airflow.cfg to True.

Add custom alert messages on the dashboard

New in version 2.2.0.

Extra alert messages can be shown on the UI dashboard. This can be useful for warning about setup issues or announcing changes to end users. The following example shows how to add a simple alert message:

  1. Create airflow_local_settings.py file and put in on $PYTHONPATH or to $AIRFLOW_HOME/config folder. (Airflow adds $AIRFLOW_HOME/config on PYTHONPATH when Airflow is initialized)

  2. Add the following contents to airflow_local_settings.py file.

    1. from airflow.www.utils import UIAlert
    2. DASHBOARD_UIALERTS = [
    3. UIAlert("Welcome to Airflow"),
    4. ]
  3. Restart Airflow Webserver, and you should now see:

../_images/ui-alert-message.png

You can also control the category of the alert message as well the roles it should be shown to. For example, to show a warning message to users in the User role:

  1. DASHBOARD_UIALERTS = [
  2. UIAlert("Airflow update happening next week", category="warning", roles=["User"]),
  3. ]

HTML can also be included in the messages, though care must be taken to ensure it is done safely. If your message is safe, you can simply set html=True, otherwise use string formatting. For more information, see String Formatting in the MarkupSafe docs.

  1. DASHBOARD_UIALERTS = [
  2. UIAlert('Visit <a href="https://airflow.apache.org">airflow.apache.org</a>', html=True),
  3. UIAlert(Markup("Welcome <em>%s</em>") % ("John & Jane Doe",)),
  4. ]