Skip to content

Commit 467148b

Browse files
committed
docs: add docs for custom alert messages
1 parent be6c46e commit 467148b

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

airflow-core/docs/howto/customize-ui.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,40 @@ After
6464
.. note::
6565

6666
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``.
67+
68+
69+
Add custom alert messages on the dashboard
70+
------------------------------------------
71+
72+
Extra alert messages can be shown on the UI dashboard. This can be useful for warning about setup issues
73+
or announcing changes to end users. The following example shows how to add alert messages:
74+
75+
1. Add the following contents to ``airflow_local_settings.py`` file under ``$AIRFLOW_HOME/config``.
76+
Each alert message should specify a severity level (``info``, ``warning``, ``error``) using ``category``.
77+
78+
.. code-block:: python
79+
80+
from airflow.api_fastapi.common.types import UIAlert
81+
82+
DASHBOARD_UIALERTS = [
83+
UIAlert(text="Welcome to Airflow.", category="info"),
84+
UIAlert(text="Airflow server downtime scheduled for tomorrow at 10:00 AM.", category="warning"),
85+
UIAlert(text="Critical error detected!", category="error"),
86+
]
87+
88+
See :ref:`Configuring local settings <set-config:configuring-local-settings>` for details on how to
89+
configure local settings.
90+
91+
2. Restart Airflow Webserver, and you should now see:
92+
93+
.. image:: ../img/ui-alert-message.png
94+
95+
Alert messages also support Markdown. In the following example, we show an alert message of heading 2 with a link included.
96+
97+
.. code-block:: python
98+
99+
DASHBOARD_UIALERTS = [
100+
UIAlert(text="## Visit [airflow.apache.org](https://airflow.apache.org)", category="info"),
101+
]
102+
103+
.. image:: ../img/ui-alert-message-markdown.png
Loading
-6.57 KB
Loading

0 commit comments

Comments
 (0)