wallix / awless

A Mighty CLI for AWS
http://awless.io/
Apache License 2.0
4.98k stars 263 forks source link

Adding filter for only running non-spot instances and more price stats #127

Closed deinspanjer closed 5 months ago

deinspanjer commented 7 years ago

I'm having trouble with the currently configured service (ec2-price.com) not returning data very often, but I figured I should paste an example of the new output anyway:

➜  awless git:(enhanced-pricer) awl inspect -i pricer
[info]    Running full sync before inspection (disable it with --local flag)

Fetching prices at http://ec2-price.com for region global

fetching price for 'm3.medium': strconv.ParseFloat: parsing "": invalid syntax
fetching price for 't2.small': strconv.ParseFloat: parsing "": invalid syntax
fetching price for 'm4.large': strconv.ParseFloat: parsing "": invalid syntax
fetching price for 't2.medium': strconv.ParseFloat: parsing "": invalid syntax
fetching price for 't2.micro': strconv.ParseFloat: parsing "": invalid syntax
fetching price for 't2.large': strconv.ParseFloat: parsing "": invalid syntax
fetching price for 't1.micro': strconv.ParseFloat: parsing "": invalid syntax

and the desired output:

Instance    Count       Price ea.   Estimated Total Cost (no EBS)
Type        Running     Per Hour    Per Day     Per Month
--------    -------     ---------   -------     ---------
m4.large          1      0.00000        0.00        0.00
t2.small         12      0.00000        0.00        0.00
t2.medium         6      0.00000        0.00        0.00
m3.medium         1      0.00000        0.00        0.00
t2.micro          1      0.00000        0.00        0.00
t1.micro          2      0.00000        0.00        0.00
t2.large          1      0.00000        0.00        0.00
        -------             -------     ---------
Grand Total      24                 0.00        0.00
deinspanjer commented 7 years ago

Any thoughts about switching to the official price list API? ( http://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/price-changes.html ) It is a lot more verbose, but it seems like the kind of thing that could be stored in the RDF and used in several places such as awless list instances.

simcap commented 7 years ago

Are you saying the current API for pricing ec2-price.com is sometimes down or not reliable?

The current pricing API was chosen as a temporary (but accurate) one indeed before getting more into serious pricing: infrastructure pricing, templates pricing, etc ...

The idea is indeed, as you say, to have the official AWS pricing data fetch dynamically and cached locally for more diverse uses.

simcap commented 7 years ago

As per your PR I am not clear on what you are trying to achieve for a pricing output (although a more complete might be useful indeed).

I can see filtering on the running instances could be useful, but it also a specific use case. We might need to pass params down to the inspector to have more control on the output maybe.

deinspanjer commented 7 years ago

Are you saying the current API for pricing ec2-price.com is sometimes down or not reliable?

Yes, most of the time when I try running the pricing inspector, it returns the output I pasted in the comment above.

The current pricing API was chosen as a temporary (but accurate) one indeed before getting more into serious pricing: infrastructure pricing, templates pricing, etc ... The idea is indeed, as you say, to have the official AWS pricing data fetch dynamically and cached locally for more diverse uses.

That seems like it would be fun. Can't make any promises, but I'd be happy to try helping out here and there.

As per your PR I am not clear on what you are trying to achieve for a pricing output (although a more complete might be useful indeed).

I can see filtering on the running instances could be useful, but it also a specific use case. We might need to pass params down to the inspector to have more control on the output maybe.

So when I run the current pricing inspector and look at the results, it gives a monthly price that is vastly larger than the amount we actually pay. The reason for that is because we have several instances that are spot prices, and many instances that are currently stopped.

I thought the idea of this inspector was to give you a quick and dirty estimate of how much you might expect to pay for the resources you are currently being charged for.

That is why I removed things you wouldn't pay the on-demand fee on (stopped and spot) as well as a per day price.

simcap commented 7 years ago

Ok. Thanks for the clarification.

So is the new pricer (expect the issue of the intermittent ec2-price.com) giving you valid estimates that reconcile with your monthly bill ? Looking at your new columns output it also makes sense in term of reporting.

Do any last corrections if needed. I will run through it, test it locally and will merge it accordingly in the next few days.

Thanks.

deinspanjer commented 7 years ago

Yes, it aligns with the line items for EC2 run hours minus EBS charges. I think there are lots of fun things that could be added, especially with some mechanism for configuration or parameters, but this feels like a good incremental improvement to what is currently there.

simcap commented 7 years ago

I have run it locally. Here a a few remarks.