Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Accept command line flags for setting dates, and ideally tags to filter by #9

Open
mrchrisadams opened this issue Aug 13, 2019 · 5 comments
Milestone

Comments

@mrchrisadams
Copy link
Member

mrchrisadams commented Aug 13, 2019

Right now the we have hard coded dates for running checks.

There's a normal 1 year rolling window I think for cost explorer, but it would be nice to set the time bounds, like you can with the python cli.

For example, when you have this:

aws ce get-cost-and-usage --time-period Start=2018-08-01,End=2019-05-01 --granularity MONTHLY --metrics "BlendedCost" "UsageQuantity" --group-by Type=DIMENSION,Key=AZ

I would be good to do something to either use the same kinds of flags:

greencost --time-period Start=2018-08-01,End=2019-05-01

Or ideally use flags like so, which

I'm not sure what the convention is for node js, but if we know we only ever have maximum of today plus one year back, we might be able to have some sensible defaults to show the last year of spend analysis, or be able to set arbitrary figures like so:

greencost --time-period-start 2018-08-01 --time-period-end 2019-05-01

I'm not sure what the most command CLI tool for node is, but commander looks well documented, and is used by the Vue CLI, so there's code examples we can look to for seeing how different things are implemented

https://www.npmjs.com/package/commander

### Bonus bit

If filtering by tags is simple, then it gives us a nice way to restrict a query to a single project team.

https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_GetCostAndUsage.html#API_GetCostAndUsage_RequestSyntax

@mrchrisadams mrchrisadams mentioned this issue Aug 15, 2019
5 tasks
@mrchrisadams
Copy link
Member Author

After chatting, we'll use meow, instead of commander.

Mapbox already use it, and well… better gifs.

@mrchrisadams
Copy link
Member Author

After convo, we're punting the tag decisions till we have first part built, and see how ppl use it.

@mrchrisadams mrchrisadams added this to the First release milestone Aug 15, 2019
@mrchrisadams
Copy link
Member Author

This is the API we agreed on

  • Call greencost by itself, to get the summary output

flags

  • --help to get hints like what we outline here
  • --by-month to get the monthly breakdown
  • --by-service to get the per service breakdown
  • --by-region to get the per region breakdown
  • --html to output as a chart you can see in browser (ideally using a charting library, like vega-embed)
  • --json to get json for consuming in other systems (this is mutually exclusive with --html)

IMG_20190815_154918

@edsu
Copy link
Contributor

edsu commented Nov 3, 2019

At the moment the utility throws an error since the dates that are hard coded request data that's more than 12 months ago, which the API does not support.

edsu added a commit to edsu/green-cost-explorer that referenced this issue Nov 3, 2019
Until thegreenwebfoundation#9 is resolved I thought it would be useful if the tool defaults
to the last 12 months of activity instead of having hard coded dates
that prevent it from running with an error.

I thought this could be useful since people may try out the utility
after the recent blog post by Mapbox:

https://blog.mapbox.com/how-much-carbon-is-your-server-emitting-d7edf3496fd6
@edsu edsu mentioned this issue Nov 3, 2019
mrchrisadams pushed a commit that referenced this issue Nov 4, 2019
Until #9 is resolved I thought it would be useful if the tool defaults
to the last 12 months of activity instead of having hard coded dates
that prevent it from running with an error.

I thought this could be useful since people may try out the utility
after the recent blog post by Mapbox:

https://blog.mapbox.com/how-much-carbon-is-your-server-emitting-d7edf3496fd6
@mrchrisadams
Copy link
Member Author

Thanks for changing the hard coding, @edsu.

I based on on the extra bits, I'm going to leave this open in the hope that me, or some kind soul from the internet is able to add the parsing of flags for specific dates 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants