There was a significant increase in my Amazon Elastic Container Service (Amazon ECS) costs. I want to understand my Amazon ECS spending. Or, I want to use the AWS Cost Explorer to analyze my Amazon ECS costs.
Resolution
Use the AWS Cost Explorer to view your Amazon ECS costs
You can use the AWS Cost Explorer to check historical and forecasted data about your Amazon ECS costs.
Important: After you opt in to the AWS Cost Explorer, you can't opt out of it.
Filter Amazon ECS costs in AWS Cost Explorer
To view your Amazon Elastic Compute Cloud (Amazon EC2) usage costs in the AWS Cost Explorer, complete the following steps:
- Open the AWS Billing and Cost Management console.
- In the navigation pane, choose Cost Explorer, and then configure the following settings:
Select a Date range and Granularity.
For Dimension, select Service.
Under Filters, for Service, select Elastic Container Service.
For Usage type, select USE1-ECS-EC2-GB-Hours (GB-Hours) and USE1-ECS-EC2-vCPU-Hours (vCPU-Hours).
Note: The Usage type filter organizes costs by AWS Region.
For Tag, select the tag assigned to your Amazon ECS container instances.
For more information, see Exploring your data using Cost Explorer.
For information about how to filter the AWS Cost Explorer to view AWS Fargate costs, see Cost optimization checklist for Amazon ECS and AWS Fargate.
To view your monthly Amazon ECS charges separately for Amazon EC2 and Fargate memory and CPU, use the following filters:
- ECS-EC2-GB-Hours
- ECS-EC2-vCPU-Hours
- AWS Fargate - Memory
- AWS Fargate - vCPU
Note: If you're only using Fargate, then the Amazon EC2 charges are listed as 0.
Analyze your Amazon ECS costs
Use the following best practices for your Amazon ECS cost analysis:
Use Spot Instances to optimize costs
Use Amazon EC2 or Fargate Spot Instances to optimize Amazon ECS costs. When you use Spot Instances for the workload, use the following best practices:
Fargate Spot pricing offers a discounted rate to run Amazon ECS tasks. For more information, see Deep dive into Fargate Spot to run your Amazon ECS tasks for up to 70% less.
Reduce data transfer charges when you run Amazon ECS tasks
You can deploy Amazon ECS tasks in a private subnet that uses a NAT gateway to access Amazon Elastic Container Registry (Amazon ECR) images. When you do this, you incur data transfer charges on the container instance or Fargate. For each new task that doesn't have the container image locally available on the container instance, Amazon ECS downloads the image through the NAT gateway. To mitigate these costs, set up virtual private cloud (VPC) endpoints for Amazon ECR.
Related information
Analyzing your costs and usage with AWS Cost Explorer
Understanding data transfer costs for AWS container services
EC2 Spot workshops