3

I'm trying to request the CPUUtilization from my ec2 instance and following this Command Reference i'm using the following command

aws cloudwatch get-metric-statistics --metric-name CPUUtilization --start-time 2016-08-08T22:48:00 --end-time 2016-08-08T22:53:00 --period 60 --namespace AWS/EC2 --statistics Maximum --dimensions Name=InstanceId,Value=i-myinstanceid

my response is:

{
    "Datapoints": [
        {
            "Timestamp": "2016-08-08T22:51:00Z",
            "Maximum": 0.17,
            "Unit": "Percent"
        }
    ],
    "Label": "CPUUtilization"
}

but shouldn't this return me Data Points with Timestamp within 1 minute?

joshweir
  • 5,427
  • 3
  • 39
  • 59
Gabriel Brito
  • 1,003
  • 2
  • 16
  • 26

1 Answers1

2

It is not possible to retrieve actual data points from Amazon CloudWatch.

Instead, CloudWatch provides aggregated metrics over a period of time (eg Average, SampleCount, Sum).

From the CloudWatch documentation:

Amazon CloudWatch aggregates statistics according to the period length that you specify in calls to GetMetricStatistics. You can publish as many data points as you want with the same or similar time stamps. CloudWatch aggregates them by period length when you get statistics about those data points with GetMetricStatistics.

However, as you point out, CloudWatch should be returning multiple values over the given time period.

I took your command and ran it against one of my Instances. I found that, by extending the time range, I could get multiple values returned:

{
    "Datapoints": [
        {
            "Timestamp": "2016-08-08T22:52:00Z", 
            "Maximum": 0.0, 
            "Unit": "Percent"
        }, 
        {
            "Timestamp": "2016-08-08T22:47:00Z", 
            "Maximum": 0.17, 
            "Unit": "Percent"
        }, 
        {
            "Timestamp": "2016-08-08T22:42:00Z", 
            "Maximum": 0.16, 
            "Unit": "Percent"
        }, 
        {
            "Timestamp": "2016-08-08T22:37:00Z", 
            "Maximum": 0.17, 
            "Unit": "Percent"
        }
    ], 
    "Label": "CPUUtilization"
}

Notice that my data points were coming back only every 5 minutes. This is because standard monitoring of Amazon EC2 instances only captures metrics every 5 minutes. To obtain metrics at 1-minute intervals, you will need to Enable Detailed Monitoring. (Additional charges apply.)

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470