I need to do some monitoring for my various amazon ec2 instances, so my plan was originally to create a dashboard with a number widget, and choose the various things I am interested in such as "CPUUtilization", and then I can fetch that dashboard and have access to all those current metric values. However, when I make the call to get that dashboard, the body I receive is:
{"widgets"=>[{"type"=>"metric", "x"=>0, "y"=>0, "width"=>24, "height"=>6, "properties"=>{"view"=>"singleValue", "metrics"=>[["AWS/EC2", "CPUUtilization", "InstanceId", "i-0ea0081d91f6e4aff"], [".", "DiskWriteBytes", ".", "."], [".", "CPUCreditUsage", ".", "."], [".", "StatusCheckFailed", ".", "."], [".", "NetworkPacketsIn", ".", "."], [".", "NetworkOut", ".", "."], [".", "StatusCheckFailed_System", ".", "."], [".", "CPUCreditBalance", ".", "."], [".", "StatusCheckFailed_Instance", ".", "."], [".", "NetworkIn", ".", "."], [".", "NetworkPacketsOut", ".", "."], [".", "DiskReadBytes", ".", "."], [".", "DiskWriteOps", ".", "."], [".", "DiskReadOps", ".", "."]], "region"=>"us-east-1"}}]}
It does not contain any metric data, only the names of the metrics.. So this is not helpful.
The list_metrics method looks promising, except for two things...
1) It wants a single metric? Even though the docs describe the method "List the specified metrics."
The input is an object, not an array, and to use this method, I have to do:
client.list_metrics({ namespace: "AWS/EC2", metric_name: "CPUUtilization", dimensions: [ { name: "InstanceId", value: "i-0fc0181c98e6e4a66" }, ],})
Which gives me this object back:
#<struct Aws::CloudWatch::Types::ListMetricsOutput metrics=[#<struct Aws::CloudWatch::Types::Metric namespace="AWS/EC2", metric_name="CPUUtilization", dimensions=[#<struct Aws::CloudWatch::Types::Dimension name="InstanceId", value="i-0fc0181c98e6e4a66">]>], next_token=nil>
Which leads to 2) it returns just the metric name, no actual values...
What am I doing wrong?
How can I simply ask for a whole bunch of metrics for various instance ids, and get a response back that contains the actual metric values for the metrics I requested?