This is just memorandum to extract CPUUtilization with AWS CLI because I'm considering using Zabbix or Sensu to monitor the instances on AWS and thinking of how to extract each metrics, such as CPU usage, Memory usage, or Traffic.
Writing plugins will be helpful but the simplest way and using functions which they offer are easier than writing plugins, I believe.
Listing metrics of AWS/EC2
$ aws cloudwatch list-metrics --namespace AWS/EC2 --dimensions Name=InstanceType,Value=t1.micro
{
"Metrics": [
{
"Namespace": "AWS/EC2",
"Dimensions": [
{
"Name": "InstanceType",
"Value": "t1.micro"
}
],
"MetricName": "NetworkOut"
},
{
"Namespace": "AWS/EC2",
"Dimensions": [
{
"Name": "InstanceType",
"Value": "t1.micro"
}
],
"MetricName": "DiskWriteOps"
},
{
"Namespace": "AWS/EC2",
"Dimensions": [
{
"Name": "InstanceType",
"Value": "t1.micro"
}
],
"MetricName": "DiskWriteBytes"
},
{
"Namespace": "AWS/EC2",
"Dimensions": [
{
"Name": "InstanceType",
"Value": "t1.micro"
}
],
"MetricName": "CPUUtilization"
},
{
"Namespace": "AWS/EC2",
"Dimensions": [
{
"Name": "InstanceType",
"Value": "t1.micro"
}
],
"MetricName": "DiskReadOps"
},
{
"Namespace": "AWS/EC2",
"Dimensions": [
{
"Name": "InstanceType",
"Value": "t1.micro"
}
],
"MetricName": "DiskReadBytes"
},
{
"Namespace": "AWS/EC2",
"Dimensions": [
{
"Name": "InstanceType",
"Value": "t1.micro"
}
],
"MetricName": "NetworkIn"
}
]
}
Getting metrics of CPUUtilization
$ aws cloudwatch get-metric-statistics \
--namespace AWS/EC2 \
--metric-name CPUUtilization \
--dimensions Name=InstanceId,Value=i-xxx \
--statistics Average \
--start-time `date -u '+%FT%TZ' -d '10 mins ago'` \
--end-time `date -u '+%FT%TZ'` \
--period 60
{
"Datapoints": [
{
"Timestamp": "2013-11-30T11:13:00Z",
"Average": 5.6659999999999995,
"Unit": "Percent"
},
{
"Timestamp": "2013-11-30T11:18:00Z",
"Average": 6.6659999999999995,
"Unit": "Percent"
}
],
"Label": "CPUUtilization"
}
Extracting average with jq command
$ aws cloudwatch get-metric-statistics \
--namespace AWS/EC2 \
--metric-name CPUUtilization \
--dimensions Name=InstanceId,Value=i-xxx \
--statistics Average \
--start-time `date -u '+%FT%TZ' -d '10 mins ago'` \
--end-time `date -u '+%FT%TZ'` \
--period 60 | jq '.Datapoints[0] | .Average'
6.6659999999999995
did you paste twice on that last one? btw, do you know you are the only one online posting this info? that i could find quick.
ReplyDeleteThat was just typo, so I fixed it. Thx!
Deleteplease, post more if you have experienced, very valuable, thanks, cheers, over
DeleteThere are many game soft rte. children. It makes lot of attraction for them. The specified game help or the player. Theming and body lead them in attraction style and mode.
ReplyDeleteI simply wanted to write down a quick word to say thanks to you for
ReplyDeletethose wonderful tips and hints you are showing on this site.
AWS Training in Chennai
AWS Training in Bangalore
AWS Training in Bangalore
This comment has been removed by the author.
ReplyDeleteI feel really happy to have seen your webpage and look forward to so
ReplyDeletemany more entertaining times reading here. Thanks once more for all
the details.
aws training in chennai
You’ll be informed that your PC must be rebooted for Check Disk to complete, so make sure you have closed all of your applications first. Going Here to know more.
ReplyDeleteReally nice blog post.provided a helpful information.I hope that you will post more updates like this
ReplyDeleteAWS Online Training
Great Blog to read, It gives more useful information. Thank lot.
ReplyDeleteBest Tableau Training Institute in Pune
Apache Spark Training Institute in Pune
Best AWS Training Institute in Pune