Small Python pipeline to:
- query recent cloud costs from DoiT Reports API,
- generate optimization recommendations with Ava,
- filter near-duplicates against existing FinOps insights,
- create custom insights via Insights API.
- Python 3.10+
- Dependencies from
requirements.txt:requestspython-dotenv
Install:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtCreate .env with:
DOIT_API_KEY=...
CUSTOMER_CONTEXT=... # read/query context
DOIT_API_KEY_WRITES=... # write key used for insight creation
CUSTOMER_CONTEXT_WRITES=... # write context used for insight creation
# Optional:
# MAX_INSIGHTS_WRITE=1Notes:
DOIT_API_KEY_WRITESis required for the insight-creation phase.CUSTOMER_CONTEXT_WRITESis required for the insight-creation phase.- Account/identity used for writes needs Insights Manager permission.
Normal run (uses cached files when present):
python3 report.pyForce full refresh:
python3 report.py --forceLimit number of insight writes (default: 1, or MAX_INSIGHTS_WRITE if set):
python3 report.py --max-insights-write 3report.py runs these phases:
- Query phase: fetches last-month costs from Reports API.
- Ava phase: generates optimization recommendations from cost data.
- Insights read phase: fetches existing FinOps insights.
- Compare/filter phase: removes recommendations similar to existing insights.
- Insights write phase: creates custom insights from filtered recommendations.
cost_report_data.jsonava_generated_with_significant_value.jsonexisting_insights.jsonava_recommendations_filtered.jsoninsights_created_results.json
insights_created_results.json includes:
createdcount,errorswith response details on failures,created_insightswhen at least one insight is successfully created.
- Reports query endpoint on
https://api.doit.com/analytics/v1/reports/query - Ava endpoint on
https://api.doit.com/ava/v1/askSync - Insights endpoint on
https://api.doit.com/insights/v1/results
Docs: