Skip to main content

A DAG cost tracking plugin for Apache Airflow

Project description

💰 DAG Cost Tracker

PyPI - Version Python Version License

DAG Cost Tracker is a powerful observability and FinOps tool designed for Apache Airflow. It tracks execution time and compute resource usage to provide granular cost estimates for individual DAG runs, helping engineering teams optimize their data pipeline spending.


🚀 Features

  • Granular Cost Tracking: Track costs at the DAG and task level.
  • Customizable Pricing: Configure warehouse rates (e.g., Snowflake credits) to match your contract.
  • CLI Reporting: Generate beautiful cost reports and inspect expensive DAGs from your terminal.
  • Seamless Integration: Plugs directly into Airflow task hooks—no DAG code changes required.
  • Lightweight: Stores cost history in a local SQLite database (zero external infrastructure dependencies).

📦 Installation

Install easily via pip:

pip install dag-cost-tracker

⚙️ Configuration

  1. Create Config File: Create a config.yaml at ~/.dag_cost_tracker/config.yaml to define your compute pricing.

    warehouses:
      COMPUTE_WH_SMALL:
        credits_per_hour: 1
        cost_per_credit: 3.00
      COMPUTE_WH_LARGE:
        credits_per_hour: 4
        cost_per_credit: 3.00
    
  2. Enable Plugin: The plugin auto-registers with Airflow upon installation. Restart your Airflow Scheduler and Webserver to start tracking.

📊 Usage

Generate a Cost Report

See your most expensive DAGs at a glance:

dag-cost report --top 10 --period 30d

Output:

+-------------------+--------+--------------+----------------+
| DAG ID            |   Runs | Total Cost   | Avg Cost/Run   |
+===================+========+==============+================+
| etl_daily         |      7 | $148.66      | $21.24         |
+-------------------+--------+--------------+----------------+
| ml_training       |      7 | $115.77      | $16.54         |
+-------------------+--------+--------------+----------------+

Inspect a Specific DAG

Drill down to find which tasks are driving up costs:

dag-cost inspect etl_daily

🛠️ Development

  1. Clone the repository.
  2. Install dependencies: pip install -e .
  3. Run tests: pytest

👤 Author

Azmat Siddique

If you found this tool useful, consider buying me a coffee!

Buy Me A Coffee

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dag_cost_tracker-0.1.1-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file dag_cost_tracker-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for dag_cost_tracker-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 93d821455fc3f28b1dc5369c5c7c701aab3d09fc12e31109c255de33588fc0c4
MD5 afe6aaddab990740e347dc0fd522714d
BLAKE2b-256 cca71051d1d6b48c3756e45384dc7b69f06a6d72f219f5c8a28e7236fe600fd4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page