View a markdown version of this page

获取指标统计数据(GetMetricStatistics) - Amazon CloudWatch

获取指标统计数据(GetMetricStatistics)

GetMetricStatistics 是旧版单一指标 API。新代码请改用 检索指标数据(GetMetricData),该方式支持批量查询和数学表达式。

用量

aws cloudwatch get-metric-statistics \ --namespace "AWS/EC2" \ --metric-name "CPUUtilization" \ --dimensions Name=InstanceId,Value=i-1234567890abcdef0 \ --start-time $(date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%S) \ --end-time $(date -u +%Y-%m-%dT%H:%M:%S) \ --period 300 \ --statistics Average Maximum

该 API 适用场景

  • 依赖该 API 的存量应用程序

  • 仅需简单单一指标查询场景(无需批量查询)

其他场景请使用 检索指标数据(GetMetricData)