Skip to main content

💰 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

Metadata

Release files for dag-cost-tracker 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for dag-cost-tracker 0.1.3
File Interpreter ABI Platform
dag_cost_tracker-0.1.3-py3-none-any.whl Python 3 none any Details

Release files / dag_cost_tracker-0.1.3-py3-none-any.whl

Download URL dag_cost_tracker-0.1.3-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4f1ecf16e26e49e9adbd3b6815764f2b957fb42c3f03cff13842e1da2d87b418
BLAKE2b-256 checksum
How to use checksums
f9f402ec35d794b060e36756e2f17fde1a41151747689fb364c34d9deb2d69a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.5

Release history Release notifications | RSS feed

This release

0.1.3 This release

1 release file

0.1.1

1 release file

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page