Find hidden AWS costs with Compute Optimizer and Cost Optimization Hub
Most AWS accounts are overspending by 20-30% on compute alone. The good news: AWS gives you free tools to find exactly where the waste is. You don’t need a third-party platform or a FinOps certification to get started.
This post covers two tools that work together: Compute Optimizer for right-sizing recommendations and Cost Optimization Hub for a single dashboard of all savings opportunities. I’ll also walk through installing the CloudWatch agent, which feeds Compute Optimizer the memory data it needs to make accurate recommendations.
Enable Compute Optimizer
Compute Optimizer analyzes your EC2 instances, EBS volumes, Lambda functions, and ECS services against their actual utilization. It tells you when something is over-provisioned, under-provisioned, or running on an outdated instance family.
Open the Compute Optimizer console and click Opt in. If you have multiple accounts, opt in from the management account to cover the entire organization.
aws compute-optimizer update-enrollment-status --status Active
It takes about 12 hours to generate initial recommendations after opting in. Compute Optimizer needs at least 30 hours of CloudWatch metrics to analyze a resource, so new instances won’t show up immediately.
What Compute Optimizer finds
Once it has enough data, Compute Optimizer flags resources in four categories:
- Over-provisioned: you’re paying for capacity you’re not using. An
m5.2xlargerunning at 8% CPU belongs on am5.large. - Under-provisioned: the instance is maxing out and affecting performance. Cheaper to right-size now than debug latency issues later.
- Outdated instance family: running
m4orc4whenm7iorc7g(Graviton) would be cheaper and faster. - EBS volumes: gp2 volumes that should be gp3 (gp3 is cheaper and faster by default), or volumes with provisioned IOPS you’re not using.
List your EC2 recommendations from the CLI:
aws compute-optimizer get-ec2-instance-recommendations \
--query "instanceRecommendations[].{
Instance:instanceArn,
Current:currentInstanceType,
Finding:finding,
Recommended:recommendationOptions[0].instanceType,
Savings:recommendationOptions[0].estimatedMonthlySavings.value}" \
--output table
This gives you a table of every instance with its current type, finding, recommended type, and estimated monthly savings.
Install CloudWatch agent for memory metrics
Here’s the thing most people miss: Compute Optimizer only uses CPU and network metrics by default because CloudWatch doesn’t collect memory utilization natively. Without memory data, it can only recommend based on CPU, which leads to aggressive downsizing recommendations that might cause OOM kills.
Install the CloudWatch agent to report memory metrics. This gives Compute Optimizer the full picture.
Amazon Linux / RHEL
sudo yum install -y amazon-cloudwatch-agent
Ubuntu / Debian
wget https://amazoncloudwatch-agent.s3.amazonaws.com/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb
sudo dpkg -i amazon-cloudwatch-agent.deb
rm amazon-cloudwatch-agent.deb
Create the agent config at /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json:
{
"metrics": {
"namespace": "CWAgent",
"metrics_collected": {
"mem": {
"measurement": ["mem_used_percent"],
"metrics_collection_interval": 300
},
"disk": {
"measurement": ["disk_used_percent"],
"resources": ["*"],
"metrics_collection_interval": 300
}
},
"append_dimensions": {
"InstanceId": "${aws:InstanceId}"
}
}
}
Start the agent:
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl \
-a fetch-config \
-m ec2 \
-c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json \
-s
Verify it’s running:
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a status
You should see "status": "running". Give Compute Optimizer a couple of days with memory data before acting on its recommendations. The accuracy improves significantly.
For fleets with many instances, deploy the agent through SSM Run Command or bake it into your AMI with Packer so every new instance reports memory from boot.
Cost Optimization Hub
Cost Optimization Hub is a newer service (launched late 2023) that aggregates savings recommendations from Compute Optimizer, Savings Plans, Reserved Instances, and other AWS services into one dashboard.
Enable it from the management account:
aws cost-optimization-hub update-enrollment-status --status Active
Once active, the hub shows you:
- Total estimated monthly savings across all recommendation types
- Right-sizing opportunities from Compute Optimizer
- Savings Plans and Reserved Instance purchase recommendations
- EBS gp2-to-gp3 migration opportunities
- Idle resources (load balancers, Elastic IPs, unattached EBS volumes)
Pull a summary of all recommendations:
aws cost-optimization-hub list-recommendations \
--query "items[].{
Type:recommendationId,
Resource:resourceArn,
Action:actionType,
MonthlySavings:estimatedMonthlySavings.value}" \
--output table \
--max-items 20
I find this more useful than clicking through the console. Export to CSV, sort by savings, and tackle the biggest items first.
A practical workflow
Here’s how I approach cost reviews for clients:
- Enable both tools (Compute Optimizer + Cost Optimization Hub) from the management account
- Install CloudWatch agent on all EC2 instances for memory metrics
- Wait 7 days for enough data to accumulate
- Pull recommendations and sort by estimated savings
- Start with the easy wins: gp2-to-gp3 volume migrations (zero downtime), old-gen instance upgrades, and idle resources
- Right-size carefully: validate memory usage before downsizing. A 10% CPU instance with 85% memory usage should not be downsized.
- Track savings month over month in Cost Explorer
Coming up next
These tools find where you’re overspending today, but they don’t prevent cost surprises tomorrow. In the next post, I’ll cover billing alarms, AWS Budgets with alerts, and Cost Anomaly Detection to set up guardrails that catch unexpected spend before it hits your invoice.