aws-cost-explorer
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAWS Cost Explorer
AWS Cost Explorer
Query AWS costs and usage details with flexible granularity - from service-level overview to detailed usage type breakdown.
查询AWS成本和使用详情,支持灵活的粒度——从服务级概览到详细的使用类型细分。
Capabilities
功能
- Query daily AWS costs by service (e.g., EC2, S3, OpenSearch, DocumentDB)
- Drill down to usage type details for specific services (e.g., instance types, storage, data transfer)
- Filter results by minimum cost threshold
- Support both relative dates (days ago) and absolute dates (YYYY-MM-DD)
- Output in human-readable table or JSON format
- 按服务查询每日AWS成本(如EC2、S3、OpenSearch、DocumentDB)
- 深入查看特定服务的使用类型详情(如实例类型、存储、数据传输)
- 按最低成本阈值过滤结果
- 支持相对日期(几天前)和绝对日期(YYYY-MM-DD)
- 输出人类可读的表格或JSON格式
Usage
使用方法
Quick Commands
快速命令
To query costs, use the bundled script at :
scripts/cost_query.pybash
undefined要查询成本,使用中的捆绑脚本:
scripts/cost_query.pybash
undefinedQuery costs from 2 days ago (default) by service
查询2天前(默认)的按服务划分的成本
python3 <skill-path>/scripts/cost_query.py
python3 <skill-path>/scripts/cost_query.py
Query yesterday's costs, show items > $5
查询昨天的成本,显示金额超过5美元的项目
python3 <skill-path>/scripts/cost_query.py --days-ago 1 --min-cost 5
python3 <skill-path>/scripts/cost_query.py --days-ago 1 --min-cost 5
Query specific date
查询特定日期的成本
python3 <skill-path>/scripts/cost_query.py --date 2026-01-15
python3 <skill-path>/scripts/cost_query.py --date 2026-01-15
Query specific service's usage breakdown
查询特定服务的使用细分
python3 <skill-path>/scripts/cost_query.py --service "Amazon OpenSearch Service" --min-cost 1
python3 <skill-path>/scripts/cost_query.py --service "Amazon OpenSearch Service" --min-cost 1
Query all services with usage type details
查询所有服务的使用类型详情
python3 <skill-path>/scripts/cost_query.py --detailed --min-cost 5
python3 <skill-path>/scripts/cost_query.py --detailed --min-cost 5
Output as JSON
以JSON格式输出
python3 <skill-path>/scripts/cost_query.py --json --min-cost 5
undefinedpython3 <skill-path>/scripts/cost_query.py --json --min-cost 5
undefinedScript Options
脚本选项
| Option | Short | Description |
|---|---|---|
| | Query N days ago (default: 2, i.e., day before yesterday) |
| Query specific date (YYYY-MM-DD format) | |
| | Minimum cost threshold to display (default: 0) |
| | Query usage type breakdown for a specific service |
| Show all services with usage type breakdown | |
| | Output in JSON format |
| 选项 | 简写 | 描述 |
|---|---|---|
| | 查询N天前的成本(默认:2,即前天) |
| 查询特定日期的成本(格式为YYYY-MM-DD) | |
| | 显示结果的最低成本阈值(默认:0) |
| | 查询特定服务的使用类型细分 |
| 显示所有服务的使用类型详情 | |
| | 以JSON格式输出 |
Common Service Names
常用服务名称
When using , use the exact AWS service names:
--service| Common Name | AWS Service Name |
|---|---|
| OpenSearch | |
| DocumentDB/MongoDB | |
| EC2 Compute | |
| EC2 Other (EBS, NAT) | |
| EFS | |
| S3 | |
| RDS | |
| EKS | |
| VPC | |
| Bedrock | |
| Lambda | |
| CloudWatch | |
使用选项时,请使用准确的AWS服务名称:
--service| 常用名称 | AWS服务名称 |
|---|---|
| OpenSearch | |
| DocumentDB/MongoDB | |
| EC2计算 | |
| EC2其他(EBS、NAT) | |
| EFS | |
| S3 | |
| RDS | |
| EKS | |
| VPC | |
| Bedrock | |
| Lambda | |
| CloudWatch | |
Understanding Usage Types
理解使用类型
Common usage type patterns:
| Pattern | Meaning |
|---|---|
| EC2 instance hours (e.g., |
| OpenSearch instance hours |
| EBS storage (e.g., |
| S3/EFS storage capacity |
| Data transfer costs |
| NAT Gateway costs |
| VPC Endpoint costs |
| Bedrock token usage |
| DocumentDB Elastic costs |
常见的使用类型模式:
| 模式 | 含义 |
|---|---|
| EC2实例时长(如 |
| OpenSearch实例时长 |
| EBS存储(如 |
| S3/EFS存储容量 |
| 数据传输成本 |
| NAT网关成本 |
| VPC终端节点成本 |
| Bedrock令牌使用量 |
| DocumentDB Elastic成本 |
Prerequisites
前提条件
- AWS CLI configured with appropriate credentials
- IAM permissions for
ce:GetCostAndUsage
- 已配置具有适当凭证的AWS CLI
- 拥有的IAM权限
ce:GetCostAndUsage
Example Workflow
示例工作流
-
First, get service-level overview:bash
python3 <skill-path>/scripts/cost_query.py --min-cost 5 -
Identify high-cost services, then drill down:bash
python3 <skill-path>/scripts/cost_query.py --service "Amazon OpenSearch Service" --min-cost 1 -
For comprehensive analysis, use detailed mode:bash
python3 <skill-path>/scripts/cost_query.py --detailed --min-cost 5
-
首先,获取服务级概览:bash
python3 <skill-path>/scripts/cost_query.py --min-cost 5 -
识别高成本服务,然后深入查看:bash
python3 <skill-path>/scripts/cost_query.py --service "Amazon OpenSearch Service" --min-cost 1 -
如需全面分析,使用详细模式:bash
python3 <skill-path>/scripts/cost_query.py --detailed --min-cost 5