opencost / opencost-plugins

Plugins for extending OpenCost with new Custom Cost Sources
Apache License 2.0
19 stars 9 forks source link

Cloudflare Plugin #52

Open ameijer opened 1 month ago

ameijer commented 1 month ago

Is your feature request related to a problem? Please describe. Implement a Cloudflare plugin for the OpenCost Plugins ecosystem

Additional context Cloudflare billing data available here: https://developers.cloudflare.com/api/operations/user-billing-history-(-deprecated)-billing-history-details

Example PR with an implemented Plugin: https://github.com/opencost/opencost-plugins/pull/41 This issue qualifies for our bounty program, read more details here: https://www.opencost.io/blog/introducing-opencost-plugins

robinbihun commented 6 days ago

I'm not sure this cloudflare Billing Data API is returning data as expected, I was not able to get it to return anything for me. Additionally, as it appears to be deprecated would it be better to use the List Account Subscriptions API? I do not see any obvious APIs for other add-ons available (https://developers.cloudflare.com/support/account-management-billing/billing-add-on-service/).

Lastly, The way the Cloudflare billing appears to work is Monthly based on usage the previous month; they do not break cost/usage down into a "Hour" or "Day" resolution, but they do include the service dates the subscription charge is for. Would the desire here be to get the monthly cost and spread the cost out evenly for the requested resolution or only return the cost on the day it is billed? With the latter I imagine that the opencost dashboard would show "$0" for cloudflare whereas the former would at least show a "baseline [daily|hourly] cost."

ameijer commented 3 days ago

Hi Robin,

First off, I assigned you this ticket so nobody duplicates this work. hope that is OK.

Second of all, I think your idea for interpolated costs is fine - if you can adjust the description or something to append - INTERPOLATED or something to that effect so that people know what you are doing.