1

I am learning to use the aws cloudwatch get-metric-statistics subcommand in the AWS command line tool. To prove to myself that I am using the tool correctly, I would like a simple example command that should always return some data. Or, at least, that should always return some datapoints provided one has a typical minimum of deployed AWS resources.

So far, every command I have run returns zero datapoints. For example:

aws cloudwatch get-metric-statistics --metric-name CPUUtilization --start-time $(gdate -u -d '-1 hour' +%FT%T) --end-time $(gdate -u +%FT%T) --period 3600 --namespace AWS/EC2 --statistics Maximum

I was hoping that this would return at least some CPU utilization data from my EC2 instances, as a demonstration that I could get any kind of data. But I don't:

{
    "Label": "CPUUtilization",
    "Datapoints": []
}

Can anyone suggest a command that will show me something? Anything? Then, if it dosen't work, I'll at least know I'm misconfigured somehow.

1 Answers1

0

Check if it is a problem with the timestamp format:

aws cloudwatch get-metric-statistics --metric-name CPUUtilization --start-time $(gdate -u -d '-1 hour' '+%Y-%m-%dT%H:%M:%SZ') --end-time $(gdate '+%Y-%m-%dT%H:%M:%SZ') --period 3600 --namespace AWS/EC2 --statistics Maximum

Also make sure that the region is set correct

Henrik Pingel
  • 9,380
  • 2
  • 28
  • 39