AWS.CloudWatch SDK 与 CLI 产生不同的结果

AWS.CloudWatch SDK vs. CLI produces different results

我正在尝试从 AWS Cloudwatch 中提取数据。使用 CLI 时它工作正常。

aws cloudwatch get-metric-statistics --namespace AWS/ApiGateway --metric-name Count --start-time 2020-01-03T23:00:00Z --end-time 2020-01-05T23:00:00Z --period 3600 --statistics Sum  --dimensions Name=ApiName,Value=prod-api-proxy

但是当使用 nodejs 时,我得到一个空的结果集。这是代码:

var AWS = require('aws-sdk');
AWS.config.update({region: 'us-east-1'});
var cw = new AWS.CloudWatch({apiVersion: '2010-08-01'});

var params = {
    Dimensions: [
      {
          Name: 'ApiName',
          Value: 'prod-api-proxy'
      }
    ],
    MetricName: 'Count',
    Namespace: 'AWS/ApiGateway',
    StartTime: new Date('2020-01-03T23:00:00Z').toISOString(),
    EndTime: new Date('2020-01-05T23:00:00Z').toISOString(),
    Statistics: ['Sum'],
    Period: 3600
  };
  cw.getMetricStatistics(params, function(err, data) {
    if (err) {
      console.log("Error", err);
    } else {
      console.log("Metrics", JSON.stringify(data.Metrics));
    }
  })

这是我得到的空响应:

{ Dimensions: [ { Name: 'ApiName', Value: 'prod-api-proxy' } ],
  MetricName: 'Count',
  Namespace: 'AWS/ApiGateway',
  StartTime: '2020-01-03T23:00:00.000Z',
  EndTime: '2020-01-05T23:00:00.000Z',
  Statistics: [ 'Sum' ],
  Period: 3600 }
Metrics undefined

有什么想法吗?

刚刚从 AWS 支持部门得知。如果有人需要,我会在这里发布答案。我的代码有错误。对象 data.Metrics 不是响应的一部分。