AWS Cost Management
Cost Explorer
Visualize, understand, and forecast AWS costs and usage with custom reports
AWS Cost Explorer is a built-in visualization tool that lets you analyze your AWS spending and usage across services, accounts, regions, and time periods. It provides pre-built reports, custom filtering, and machine-learning-based forecasting so engineers and finance teams can understand where money is going and project future spend. For cloud engineers, Cost Explorer is the first stop when investigating unexpected bill spikes or optimizing architecture costs.
How Cost Explorer Works
Cost Explorer is enabled at the AWS Organizations management account level and aggregates billing data from all linked accounts. Data is updated once per day (not real-time) and is retained for 13 months by default. The service processes Cost and Usage Report (CUR) data and exposes it through a console UI and a programmatic API.
Every cost record is tagged with dimensions you can filter and group by:
| Dimension | Description | Example Use |
|---|---|---|
| Service | AWS service that generated the charge | Filter to only EC2 costs |
| Account | AWS account ID in your organization | Compare dev vs prod spending |
| Region | AWS region where the resource ran | Identify expensive regions |
| Usage Type | Specific usage category within a service | Separate EC2 data transfer from compute |
| Tag | Cost allocation tag on resources | Group costs by team, project, or environment |
| Purchase Option | On-Demand, Reserved, Spot, Savings Plans | Measure savings plan coverage |
| Instance Type | EC2/RDS instance family and size | Identify oversized instances |
Cost allocation tags must be activated in the Billing console before they appear in Cost Explorer. There is a 24-hour delay after activation before tagged data starts appearing.
Key Reports and Views
Cost Explorer ships with several pre-built reports that cover the most common analysis needs:
| Report | What It Shows | Best For |
|---|---|---|
| Monthly costs by service | Total spend per AWS service over time | Identifying top cost drivers |
| Monthly costs by account | Spend broken down by linked account | Chargeback and showback to teams |
| Daily costs by service | Day-over-day cost trends | Catching unexpected spikes quickly |
| RI utilization | How well Reserved Instances are being used | Finding underutilized RIs to sell |
| RI coverage | What % of usage is covered by RIs vs On-Demand | Deciding whether to buy more RIs |
| Savings Plans utilization | Commitment used vs total commitment | Ensuring you are not wasting commitments |
| Savings Plans coverage | % of eligible usage covered by Savings Plans | Identifying gaps to fill with more commitments |
Custom reports let you combine any filters and groupings, save them for recurring use, and share them across the organization.
The API endpoint for Cost Explorer charges $0.01 per request. If you are building automated reporting, batch your requests and cache results - do not call the API on every page load.
Forecasting and Anomaly Detection
Cost Explorer uses machine learning trained on your historical usage to forecast costs up to 12 months ahead. Forecasts are available at the monthly and daily granularity. The forecast includes a confidence interval (typically 80%) so you can see the expected range.
AWS Cost Anomaly Detection (a separate but related feature accessible from the Cost Explorer console) continuously monitors your costs and uses ML to alert you when spend deviates unexpectedly from the baseline. You configure monitors and alert thresholds:
| Monitor Type | Monitors | Use Case |
|---|---|---|
| AWS services | All services in an account | Catch any service-level anomaly |
| Linked account | A specific linked account | Per-team anomaly alerting |
| Cost category | A custom cost category you define | Anomalies within a business unit |
| Cost allocation tag | Resources sharing a tag value | Per-project anomaly detection |
Anomaly Detection alerts fire after the anomaly is detected, which can be hours after the cost spike starts. For immediate budget alerts (before costs accumulate), use AWS Budgets with a daily granularity alert instead.
Cost Explorer API and CLI
The GetCostAndUsage API is the core API for programmatic cost analysis. It powers custom dashboards, FinOps tooling, and automated reporting pipelines.
# Get monthly cost broken down by service for the last 3 months
aws ce get-cost-and-usage \
--time-period Start=2024-03-01,End=2024-06-01 \
--granularity MONTHLY \
--metrics "UnblendedCost" \
--group-by Type=DIMENSION,Key=SERVICE
# Get daily EC2 costs grouped by instance type
aws ce get-cost-and-usage \
--time-period Start=2024-05-01,End=2024-06-01 \
--granularity DAILY \
--metrics "UnblendedCost" "UsageQuantity" \
--filter '{"Dimensions":{"Key":"SERVICE","Values":["Amazon EC2"]}}' \
--group-by Type=DIMENSION,Key=INSTANCE_TYPE
# Get cost forecast for next 3 months
aws ce get-cost-forecast \
--time-period Start=2024-06-01,End=2024-09-01 \
--granularity MONTHLY \
--metric UNBLENDED_COSTKey API operations and their costs:
| API Operation | Cost | Returns |
|---|---|---|
| GetCostAndUsage | $0.01/request | Historical cost and usage data |
| GetCostForecast | $0.01/request | ML-based cost forecast |
| GetRightsizingRecommendations | $0.01/request | EC2 rightsizing suggestions |
| GetReservationPurchaseRecommendation | $0.01/request | RI purchase recommendations |
| GetSavingsPlansPurchaseRecommendation | $0.01/request | Savings Plans recommendations |
All Cost Explorer API calls must be made against the us-east-1 endpoint regardless of where your resources run. Use the endpoint https://ce.us-east-1.amazonaws.com.
Rightsizing Recommendations
Cost Explorer analyzes EC2 CloudWatch metrics (CPU, memory if CloudWatch agent is installed, network, disk) and recommends downsizing or changing instance types to save money without impacting performance.
The recommendation engine considers:
| Factor | Details |
|---|---|
| Lookback period | 14 days (default) or 7 days of CloudWatch data |
| Recommendation type | Downsize within family, or cross-family migration |
| Savings estimates | Based on On-Demand pricing for current vs recommended |
| Supported services | EC2 instances and Auto Scaling groups |
| Memory visibility | Requires CloudWatch agent - not available by default |
Rightsizing recommendations are based on average utilization, not peak. An instance might look underused on average but still experience bursty peaks. Always check p99 metrics in CloudWatch before acting on rightsizing recommendations.
Interview Focus Points
- 1How would you set up cost visibility across a 50-account AWS Organization with teams owning different accounts?
- 2A service cost spiked 3x overnight - walk me through how you would use Cost Explorer to diagnose the cause.
- 3What is the difference between blended, unblended, and amortized cost in Cost Explorer? When would you use each?
- 4How does Cost Explorer forecasting work and what are its limitations?
- 5What are cost allocation tags and how do you use them for showback vs chargeback?
- 6Cost Explorer API costs $0.01 per call - how would you design a cost reporting dashboard without running up a large bill on the reporting itself?
- 7What is the difference between Cost Anomaly Detection and AWS Budgets alerts? When would you use each?
- 8How do Savings Plans show up in Cost Explorer compared to On-Demand costs?