

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 取得指標的統計資料 (GetMetricStatistics)
<a name="getting-metric-statistics"></a>

`GetMetricStatistics` 是舊版的單一指標 API。對於新程式碼，請[擷取指標資料 (GetMetricData)](metrics-classic-getdata.md)改用 - 它支援批次查詢和數學表達式。

## Usage
<a name="getting-metric-statistics-usage"></a>

```
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
<a name="getting-metric-statistics-when-to-use"></a>
+ 已相依的舊版應用程式
+ 不需要批次的簡易單一指標擷取

對於其他項目，請使用 [擷取指標資料 (GetMetricData)](metrics-classic-getdata.md)。