Opsgenie Alert Notifier¶
Use the OpsgenieNotifier
to send an alert to opsgenie.
Using the Notifier¶
Send an alert to Opsgenie with a specific message.
from __future__ import annotations
from datetime import datetime
from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.providers.opsgenie.notifications.opsgenie import send_opsgenie_notification
with DAG(
"opsgenie_notifier",
start_date=datetime(2023, 1, 1),
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!"})],
)