AWS Cloud Financial Management

Cost Explorer Forecasting API Improvement

We have further enhanced our forecasting algorithm to allow a same day start date so customers can always access and view their historical and predicted costs in their Cost Management console and via Cost Explorer API without any gaps. Prior to this change, the current date was an invalid start date for calls to GetCostForecast and GetUsageForecast. Starting today, the current date is a valid start date so customers can request a current month forecast, even on the last day of the month.

Customers can use AWS Cost Explorer to estimate their cost and usage in a custom time range within the next 3 months (daily granularity) or within the next 12 months (monthly granularity). Forecasts are generated by machine learning algorithms based on customers’ historical data. Customers can also use AWS Budgets to set up custom budget thresholds and receive alert notifications when cost and usage is forecasted to exceed a user-defined threshold. You can create budgets at an aggregate level (for example, total monthly costs across all AWS service usage) or a more granular level (for example, monthly Amazon EC2 costs for a particular Linked Account). You can receive alert notifications via email, Amazon SNS, or Amazon Chime or Slack, if your cost and usage are forecasted to exceed the budget thresholds you defined.

Let’s use a real-life example to highlight the benefits of the Cost Explorer API update. Below is the current Cost Explorer dashboard experience:

To see the Cost Explorer API in action, let’s get the same results using the AWS Command Line Interface (CLI). For instructions on installing and configuring the AWS CLI, please refer to the User Guide. For more info on the Cost Explorer API, refer to the documentation here.

Current month costs

Here’s an example API call that retrieves the costs for the current month using a filter to exclude a specific RECORD_TYPE, “Refund”:

Here’s the content of filter.json:

Output:

Notes:

  • Start date should be set as the first day of the current month and End date as the first day of the following month.
  • End date is exclusive meaning the real last day included in the above example is 7-31-2020.
  • The “Charge Type” dimension in the Cost Explorer UI is called “RECORD_TYPE” in the API.
  • You can type aws ce get-cost-and-usage help in the CLI to learn what parameters and values are acceptable.
  • The AWS CLI Command Reference for get-cost-and-usage contains helpful documentation as well.

Forecasted month end costs

Using the same filter as the above example to exclude “Refund” charge type costs, we retrieve a forecast using the get-cost-forecast API.

Output:

Notes:

  • Start date should be set as the date when you run the query, for instance, if we run the query today, the Start date should be set as 7-27-2020 and End date as the first day of the following month.
  • End date is exclusive meaning the real last day included in the above example is 7-31-2020.
  • Any start date earlier than the current date will return a ValidationError exception.
  • The current date’s cost and usage will not be included as historical data, which is used as input to our forecasting analysis.

Conclusion

AWS Cost Management offers various tools to analyze, control and optimize your AWS spend. The AWS CLI is a flexible way to retrieve historical or forecasted cost and usage. We’ve enhanced our forecasting algorithm to include the same day costs so you can always access your forecasted month end data, even on the last day of the month.

 

Blog authors:

Owen Corso, Senior Product Manager, AWS Cost Management

Lutong Yang, Senior Product Manager, AWS Cost Management

Bowen Wang

Bowen Wang

Bowen is a Principal Product Marketing Manager for AWS Billing and Cost Management services. She focuses on enabling finance and business leaders to better understand the value of the cloud and ways to optimize their cloud financial management. In her previous career, she helped a tech start up enter the Chinese market.