Priority Tags for Airflow Dags
Project description
airflow-priority
Priority Tags for Airflow Dags
Overview
This repo provides Airflow Plugins for priority-driven DAG failure alerting. In layman's terms, one need only add a tag to their DAG in P1, P2, P3, P4, P5, and that dag will send a notification to:
Where P1 corresponds to highest priority, and P5 corresponds to lowest.
Installation
You can install from pip:
pip install airflow-priority
Or via conda:
conda install airflow-priority -c conda-forge
Integrations
| Integration | Metric / Tag |
|---|---|
| New Relic | airflow.custom.priority.p{1,2,3,4,5}.{failed,succeeded,running} |
| Datadog | airflow.custom.priority.p{1,2,3,4,5}.{failed,succeeded,running} |
| Discord | N/A |
| Slack | N/A |
| Symphony | N/A |
Datadog
Create a new Datadog api key following their guide.
Copy this api key into your airflow.cfg like so:
[priority.datadog]
api_key = the api key
metric = my.custom.metric # Optional metric name override, default is "airflow.custom.priority"
Ensure your dags are configured with tags and run some, it can often be convenient to have an intentionally failing P1 dag to test the integration. With this, you can now create custom monitors for the tags.
Discord
Create a new Discord application following the guide from the discord.py library.
Copy your bot's token into your airflow.cfg like so:
[priority.discord]
token = the bot's token
channel = the numerical channel ID, from the url or by right clicking
Ensure your bot is invited into any private channels.
Verbose updates
By default, only DAG failure events will be sent. On rerun, failure messages can be updated to reflect running/success.
The plugin can also be configured to always send updates, including when a DAG starts running and/or succeeds. These can also be configured to send to different channels.
[priority.discord]
# Update messages to reflect current state
update_message = true
send_success = true
channel_success = a-different-channel
send_running = true
channel_running = a-different-channel
Customizing message colors
[priority.discord]
failed_color = "#FF0000"
running_color = "#FFFF00"
success_color = "#00FF00"
New Relic
Create a new New Relic API Key following their guide. Note that the type should have INGEST - LICENSE.
Copy this api key into your airflow.cfg like so:
[priority.newrelic]
api_key = the api key
metric = my.custom.metric # Optional metric name override, default is "airflow.custom.priority"
Under Query Your Data in the New Relic UI, you can create a query for the new custom metric:
SELECT sum(`airflow.custom.priority.p1.failed`) FROM Metric FACET dag
With this, you can now create a custom alert. For fast alerting, we recommend the following parameters:
Window duration - 30 seconds
Sliding window aggregation - Disabled
Slide by interval - Not set
Streaming method - Event timer
Timer - 5 seconds
Fill data gaps with - None
Evaluation delay - Not set
Thresholds: Critical: Query result is above or equals 1 at least once in 1 minute
Slack
Configure a new slack application following the Slack Quickstart.
Ensure your application has the following scopes for public and private channel access:
channels:readgroups:readchat:write
Enable and install your Slack application into your workspace, and add it as an integration in whatever channel you want it to post.
Copy your Slack application's Oauth Token (starting with xoxb-) and your desired channel into your airflow.cfg like so:
[priority.slack]
token = xoxb-...
channel = channel-name
Verbose updates
By default, only DAG failure events will be sent. On rerun, failure messages can be updated to reflect running/success.
The plugin can also be configured to always send updates, including when a DAG starts running and/or succeeds. These can also be configured to send to different channels.
[priority.slack]
# Update messages to reflect current state
update_message = true
send_success = true
channel_success = a-different-channel
send_running = true
channel_running = a-different-channel
Customizing message colors
[priority.slack]
failed_color = "#FF0000"
running_color = "#FFFF00"
success_color = "#00FF00"
Symphony
Documentation coming soon!
[priority.symphony]
room_name = the room name
message_create_url = https://mycompany.symphony.com/agent/v4/stream/SID/message/create
cert_file = path/to/my/cert.pem
key_file = path/to/my/key.pem
session_auth = https://mycompany-api.symphony.com/sessionauth/v1/authenticate
key_auth = https://mycompany-api.symphony.com/keyauth/v1/authenticate
room_search_url = https://mycompany.symphony.com/pod/v3/room/search
AWS MWAA CloudWatch
To use with AWS MWAA, set the AWS region to match your MWAA instance.
[priority.aws]
region = "us-east-1"
Alternative Syntax
[!NOTE] AWS MWAA may require you to use the alternative configuration syntax
All scoped configuration options can be set directly under priority.
For example this:
[priority.aws]
region = "us-east-1"
Can be provided as:
[priority]
aws_region = "us-east-1"
License
This software is licensed under the Apache 2.0 license. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file airflow_priority-1.1.0.tar.gz.
File metadata
- Download URL: airflow_priority-1.1.0.tar.gz
- Upload date:
- Size: 20.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
553c73e1d252fe9f633f976d5b2d019333a52437dc5680f7ea554f0cca4c70c6
|
|
| MD5 |
83f3107c4918e668d9c9c66e2a3dde29
|
|
| BLAKE2b-256 |
d6b6dcba4b0e21e406df920e0dde61d95b7656c8f8946e4cd2485adf6cf89fb3
|
File details
Details for the file airflow_priority-1.1.0-py3-none-any.whl.
File metadata
- Download URL: airflow_priority-1.1.0-py3-none-any.whl
- Upload date:
- Size: 27.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c43ed85a2a431af97801e55ee75ea45a23f6ad97889f0a69e12e774be14b835
|
|
| MD5 |
9c6176b8ef70d7109756ebc43e717715
|
|
| BLAKE2b-256 |
a1b5947c04945a412f39bd13952e4db7cd86070aed440367c3ca9f235ae3c291
|