Ace Cloud Interviews
Home/AWS Tutorial/Cost Explorer
💰

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:

DimensionDescriptionExample Use
ServiceAWS service that generated the chargeFilter to only EC2 costs
AccountAWS account ID in your organizationCompare dev vs prod spending
RegionAWS region where the resource ranIdentify expensive regions
Usage TypeSpecific usage category within a serviceSeparate EC2 data transfer from compute
TagCost allocation tag on resourcesGroup costs by team, project, or environment
Purchase OptionOn-Demand, Reserved, Spot, Savings PlansMeasure savings plan coverage
Instance TypeEC2/RDS instance family and sizeIdentify 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:

ReportWhat It ShowsBest For
Monthly costs by serviceTotal spend per AWS service over timeIdentifying top cost drivers
Monthly costs by accountSpend broken down by linked accountChargeback and showback to teams
Daily costs by serviceDay-over-day cost trendsCatching unexpected spikes quickly
RI utilizationHow well Reserved Instances are being usedFinding underutilized RIs to sell
RI coverageWhat % of usage is covered by RIs vs On-DemandDeciding whether to buy more RIs
Savings Plans utilizationCommitment used vs total commitmentEnsuring you are not wasting commitments
Savings Plans coverage% of eligible usage covered by Savings PlansIdentifying 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 TypeMonitorsUse Case
AWS servicesAll services in an accountCatch any service-level anomaly
Linked accountA specific linked accountPer-team anomaly alerting
Cost categoryA custom cost category you defineAnomalies within a business unit
Cost allocation tagResources sharing a tag valuePer-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.

bash
# 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_COST

Key API operations and their costs:

API OperationCostReturns
GetCostAndUsage$0.01/requestHistorical cost and usage data
GetCostForecast$0.01/requestML-based cost forecast
GetRightsizingRecommendations$0.01/requestEC2 rightsizing suggestions
GetReservationPurchaseRecommendation$0.01/requestRI purchase recommendations
GetSavingsPlansPurchaseRecommendation$0.01/requestSavings 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:

FactorDetails
Lookback period14 days (default) or 7 days of CloudWatch data
Recommendation typeDownsize within family, or cross-family migration
Savings estimatesBased on On-Demand pricing for current vs recommended
Supported servicesEC2 instances and Auto Scaling groups
Memory visibilityRequires 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?