LoginSignup
0
2

More than 5 years have passed since last update.

直近1時間のCPUクレジットの推移を取得するワンライナー

Posted at

以下の {インスタンスID} はメトリクスを取得したいEC2インスタンスのインスタンスIDを指定すること。

$ aws cloudwatch get-metric-statistics \
  --namespace 'AWS/EC2' \
  --region ap-northeast-1 \
  --period 300 \
  --start-time `date +'%Y-%m-%dT%H:%M:59Z' --utc -d '60 minutes ago'` \
  --end-time `date +'%Y-%m-%dT%H:%M:59Z' --utc` \
  --metric-name CPUCreditBalance \
  --dimensions '{"Name":"InstanceId","Value":"{インスタンスID}"}' \
  --statistic Average \
  --query 'Datapoints[*].[Timestamp,Average,Unit]' \
  --output text \
  | sort

実行結果

2016-11-17T06:18:00Z    353.92  Count
2016-11-17T06:23:00Z    355.9   Count
2016-11-17T06:28:00Z    357.88  Count
2016-11-17T06:33:00Z    359.86  Count
2016-11-17T06:38:00Z    361.84  Count
2016-11-17T06:43:00Z    363.82  Count
2016-11-17T06:48:00Z    365.8   Count
2016-11-17T06:53:00Z    367.77  Count
2016-11-17T06:58:00Z    369.75  Count
2016-11-17T07:03:00Z    371.72  Count
2016-11-17T07:08:00Z    373.7   Count
2016-11-17T07:13:00Z    375.64  Count

参考

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2