airflow-metrics
airflow-metrics is an Airflow plugin for automatically sending metrics from Airflow to Datadog.
Tested For: apache-airflow>=1.10.2, <=1.10.3
Installation
pip install airflow-metrics
Optional
If you want to the metrics from BigQueryOperator and GoogleCloudStorageToBigQueryOperator, then make sure the necessary dependencies are installed.
pip install apache-airflow[gcp_api]
Setup
airflow-metrics will report all metrics to Datadog, so create an airflow connection with your Datadog api key.
airflow connections --add --conn_id datadog_default --conn_type HTTP --conn_extr '{"api_key": "<your api key>"}'
Note: If you skip this step, your airflow installation should still work but no metrics will be reported.
Usage
That's it! airflow-metrics will now begin sending metrics from Airflow to Datadog automatically.
Metrics
airflow-metrics will automatically begin reporting the following metrics
airflow.task.stateThe total number of tasks in a state where the state is stored as a tag.airflow.task.state.bqThe current number of big query tasks in a state where the state is stored as a tag.airflow.dag.durationThe duration of a DAG in ms.airflow.task.durationThe duration of a task in ms.airflow.request.durationThe duration of a HTTP request in ms.airflow.request.status.successThe current number of HTTP requests with successful status codes (<400)airflow.request.status.failureThe current number of HTTP requests with unsuccessful status codes (>=400)airflow.task.upserted.bqThe number of rows upserted by a BigQueryOperator.airflow.task.delay.bqThe time taken for the big query job from a BigQueryOperator to start in ms.airflow.task.duration.bqThe time taken for the big query job from a BigQueryOperator to finish in ms.airflow.task.upserted.gcs_to_bqThe number of rows upserted by a GoogleCloudStorageToBigQueryOperator.airflow.task.delay.gcs_to_bqThe time taken for the big query from a GoogleCloudStorageToBigQueryOperator to start in ms.airflow.task.duration.gcs_to_bqThe time taken for the big query from a GoogleCloudStorageToBigQueryOperator to finish in ms.
Configuration
By default, airflow-metrics will begin extracting metrics from Airflow as you run your DAGs and send them to Datadog. You can opt out of it entirely or opt out of a subset of the metrics by setting these configurations in your airflow.cfg
[airflow_metrics]
airflow_metrics_enabled = True
airflow_metrics_tasks_enabled = True
airflow_metrics_bq_enabled = True
airflow_metrics_gcs_to_bq_enabled = True
airflow_metrics_requests_enabled = True
airflow_metrics_thread_enabled = True`
Limitations
airflow-metrics starts a thread to report some metrics, and is not supported when using sqlite as your database.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Getting Started
Set up your virtual environment for python3 however you like.
pip install -e .
airflow initdb
airflow connections --add --conn_id datadog_default --conn_type HTTP --conn_extr '{"api_key": ""}'
Note: The last step is necessary, otherwise the plugin will not initialize correctly and will not collect metrics. But you are free to add a dummy key for development purposes.
Running Tests
pip install -r requirements-dev.txt
pytest
Metadata
Release files for airflow-metrics 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| airflow-metrics-0.1.5.tar.gz | 8.0 kB | Without provenance | Details for airflow-metrics-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| airflow_metrics-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for airflow_metrics-0.1.5-py3-none-any.whl |
Total release size: 24.5 kB
Release files / airflow-metrics-0.1.5.tar.gz
| Download URL | airflow-metrics-0.1.5.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
864f034bc2c9881d47c1c2753e673b525e895fac644ae21d1204cf12006badb8
|
|
BLAKE2b-256 checksum How to use checksums |
3984191fb3d6f42d26e801ca076d1db4e55a0e4d94d9b89e7fe95f83a9a2c4c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8
|
Release files / airflow_metrics-0.1.5-py3-none-any.whl
| Download URL | airflow_metrics-0.1.5-py3-none-any.whl |
|---|---|
| Size | 16.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
13f7f05646ba7a7a3b81abc37bfa3ef1d180202232ee620338de107742ccf270
|
|
BLAKE2b-256 checksum How to use checksums |
eafc58bc930282268fc2f3bc0d65856e8e564c78f53b4a7a3058dfe9465ca5d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8
|
Security for airflow-metrics 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.