How-to Guide for Apprise notifications

Introduction

The apprise notifier (airflow.providers.apprise.notifications.apprise.AppriseNotifier) allows users to send messages to multiple service using the various on_*_callbacks at both the DAG level and Task level.

Example Code:

from datetime import datetime
from airflow import DAG
from airflow.providers.standard.operators.bash import BashOperator
from airflow.providers.apprise.notifications.apprise import send_apprise_notification
from apprise import NotifyType

with DAG(
    dag_id="apprise_notifier_testing",
    schedule=None,
    start_date=datetime(2024, 1, 1),
    catchup=False,
    on_success_callback=[
        send_apprise_notification(body="The dag {{ dag.dag_id }} succeeded", notify_type=NotifyType.SUCCESS)
    ],
):
    BashOperator(
        task_id="mytask",
        on_failure_callback=[
            send_apprise_notification(body="The task {{ ti.task_id }} failed", notify_type=NotifyType.FAILURE)
        ],
        bash_command="fail",
    )

Was this entry helpful?