Skip to content

Instantly share code, notes, and snippets.

@judoole
Last active November 9, 2020 10:45
Show Gist options
  • Save judoole/ee48814e4964755ed140b494ef9ffd32 to your computer and use it in GitHub Desktop.
Save judoole/ee48814e4964755ed140b494ef9ffd32 to your computer and use it in GitHub Desktop.
Blogpost on OpsGenie alerting in Airflow https://medium.com/p/239ddea61d0a
class OpsGenieExceptionReporter():
def __init__(self, connection_id: str = opsgenie_default,) -> None:
self.connection_id = connection_id
def __call__(self, context) -> requests.Response:
ti: TaskInstance = context["ti"]
json = {
"message": f"Something went terribly wrong with {ti.task_id}",
"description": f"See more at {ti.log_url}",
"responders": [{"name": "my-fancy-team", "type": "team"}],
"alias": f"{ti.dag_id}.{ti.task_id}-{context['ds']}"
}
return OpsgenieAlertHook(self.connection_id).execute(json)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment