Opsgenie Alert Notifier

Use the OpsgenieNotifier to send an alert to opsgenie.

Using the Notifier

Send an alert to Opsgenie with a specific message.

tests/system/opsgenie/example_opsgenie_notifier.py[source]

from __future__ import annotations

from datetime import datetime

from airflow import DAG
from airflow.providers.opsgenie.notifications.opsgenie import send_opsgenie_notification
from airflow.providers.standard.operators.bash import BashOperator

with DAG(
    "opsgenie_notifier",
    start_date=datetime(2023, 1, 1),
    schedule=None,
    on_failure_callback=[send_opsgenie_notification(payload={"message": "Something went wrong!"})],
) as dag:
    BashOperator(
        task_id="mytask",
        bash_command="fail",
        on_failure_callback=[send_opsgenie_notification(payload={"message": "Something went wrong!"})],
    )

Was this entry helpful?