Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon AWS: How Do I Programmatically Calculate My Spending?

We are using Amazon's EC2 We would like to be able to write a program that calculates how much we spent between time to time?

We figured that it's possible to download the usage report and apply the pricing rules.. Is there any better way? Direct API? Is it possible to do it in real-time(the reports are somewhat delayed)

Usage-report: https://aws-portal.amazon.com/gp/aws/developer/account/index.html?action=usage-report

like image 265
DuduAlul Avatar asked Jun 19 '11 08:06

DuduAlul


People also ask

How can a customer track his spending on AWS in detail?

You can view the reports using spreadsheet software such as Microsoft Excel or Apache OpenOffice Calc, or access them from an application using the Amazon S3 API. AWS Cost and Usage Reports tracks your AWS usage and provides estimated charges associated with your account.

Which tool is used to estimate AWS costs during budgeting?

AWS Pricing Calculator is useful both for people who have never used AWS and for those who want to reorganize or expand their usage. AWS Pricing Calculator allows you to explore AWS services based on your use cases and create a cost estimate.

How is AWS usage calculated?

Your Amazon EC2 usage is calculated by either the hour or the second based on the size of the instance, operating system, and the AWS Region where the instances are launched. Pricing is per instance-hour consumed for each instance, from the time an instance is launched until it's terminated or stopped.

What can we use to estimate your bill with AWS?

To estimate a bill, use the AWS Pricing Calculator. Choose Create estimate, and then choose your planned resources by service. The AWS Pricing Calculator provides an estimated cost per month.


1 Answers

Unfortunately Amazon don't provide real-time data (and, in fact, you'll probably notice that the accuracy of Amazon's usage reports will vary within the current billing period), nor do they provide an API to query their current prices.

We currently do this for our systems and have found a combination of the following works well:

  • Real time estimates: estimate charges based on monitoring data (number of instances, start date, terminate date, bandwidth and IO usage per-box monitored by a custom agent looking at /proc). We pessimistically over-estimate here.
  • Recent estimate: replace total costs for real-time estimates with charges based on usage report.
  • Bill: replace total costs based on actual bill

At each estimation stage we do a very primitive adjustment so the totals work out: we apply a credit/charge to bring the figure in line with the next level of estimate.

You can spend a LOT of effort trying to get these estimates as accurate as possible - it largely depends on how much data collection and maintenance overhead you're willing to bear.

We account for usage on a per-application basis (where each Instance may be reused within an instance-hour for multiple applications) so the collection overhead and maintenance of this code is worth it.

like image 171
Peter Avatar answered Oct 05 '22 23:10

Peter