amazon-web-servicesamazon-cloudfront

Why is GetMetricData returning an empty set of values?


Using the JS AWS SDK and passing the following parameters:

{
  "StartTime": 1548111915,
  "EndTime": 1549321515,
  "MetricDataQueries": [
    {
      "Id": "m1",
      "MetricStat": {
        "Metric": {
          "MetricName": "NetworkOut",
          "Namespace": "AWS/EC2",
          "Dimensions": [
            {
              "Name": "InstanceId",
              "Value": "i-[redacted]"
            }
          ]
        },
        "Period": 300,
        "Stat": "Average",
        "Unit": "Gigabytes"
      }
    }
  ]
}

This is the output:

[
  {
    "Id": "m1",
    "Label": "NetworkOut",
    "Timestamps": [],
    "Values": [],
    "StatusCode": "Complete",
    "Messages": []
  }
]
  1. The query closely matches the sample request found at https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricData.html#API_GetMetricData_Examples

  2. I am sure that the instance is a valid instance that has definitely had NetworkOut traffic during that date range.

What reason could account for the lack of elements in Values array?


Solution

  • A better solution was to omit "Unit" altogether, which allowed AWS to choose the appropriate unit, not only in scale but in category.