0
0
AwsHow-ToBeginner · 4 min read

How to Use AWS Cost Explorer: Simple Guide for Beginners

Use AWS Cost Explorer by logging into the AWS Management Console, navigating to the Cost Explorer service, and creating reports to view your AWS spending. You can filter and group costs by service, time, or tags to understand your usage and optimize expenses.
📐

Syntax

The basic steps to use AWS Cost Explorer are:

  • Open AWS Console: Sign in to your AWS account.
  • Navigate to Cost Explorer: Find it under the Billing section.
  • Create Report: Choose a time range and filters like service or tags.
  • View Data: See charts and tables showing your costs and usage.
bash
aws ce get-cost-and-usage --time-period Start=2024-01-01,End=2024-01-31 --granularity MONTHLY --metrics BlendedCost --group-by Type=DIMENSION,Key=SERVICE
💻

Example

This example uses the AWS CLI to get monthly blended costs grouped by AWS service for January 2024.

bash
aws ce get-cost-and-usage --time-period Start=2024-01-01,End=2024-01-31 --granularity MONTHLY --metrics BlendedCost --group-by Type=DIMENSION,Key=SERVICE
Output
{ "ResultsByTime": [ { "TimePeriod": { "Start": "2024-01-01", "End": "2024-01-31" }, "Groups": [ { "Keys": ["AmazonEC2"], "Metrics": { "BlendedCost": { "Amount": "120.50", "Unit": "USD" } } }, { "Keys": ["AmazonS3"], "Metrics": { "BlendedCost": { "Amount": "45.30", "Unit": "USD" } } } ] } ] }
⚠️

Common Pitfalls

Common mistakes when using AWS Cost Explorer include:

  • Not setting the correct time-period, which can show empty or misleading data.
  • Forgetting to specify metrics like BlendedCost or UnblendedCost, resulting in no cost data.
  • Using incorrect group-by keys, causing confusing reports.
  • Not enabling Cost Explorer in the AWS account before use.
bash
aws ce get-cost-and-usage --time-period Start=2024-01-01,End=2024-01-31
# Missing metrics and group-by will cause errors or empty results

# Correct usage:
aws ce get-cost-and-usage --time-period Start=2024-01-01,End=2024-01-31 --metrics BlendedCost --group-by Type=DIMENSION,Key=SERVICE
📊

Quick Reference

Command PartDescription
--time-period Start=YYYY-MM-DD,End=YYYY-MM-DDSets the date range for cost data
--granularity DAILY|MONTHLY|HOURLYDefines how detailed the cost data is
--metrics BlendedCost|UnblendedCost|UsageQuantitySpecifies which cost or usage metric to retrieve
--group-by Type=DIMENSION,Key=SERVICE|LINKED_ACCOUNT|TAGGroups results by service, account, or tag
aws ce get-cost-and-usageAWS CLI command to fetch cost and usage data

Key Takeaways

Use AWS Cost Explorer via the AWS Console or AWS CLI to track your spending.
Always specify the time period and metrics to get meaningful cost data.
Group costs by service or tags to understand where your money goes.
Enable Cost Explorer in your AWS account before trying to use it.
Check your filters carefully to avoid empty or confusing reports.