1

无法调用 start_query 方法

我正在尝试使用以下代码查询 cloudwatch 日志。但我得到以下错误 TypeError: cloudwatchlogs.startQuery不是函数

API 似乎无法找到 startQuery 方法。请帮我解决问题。

var AWS = require('aws-sdk');
var cloudwatchlogs = new AWS.CloudWatchLogs({apiVersion: '2014-03-28',
  region: 'us-west-2'
});
// Set the region 
exports.handler = (event,context,callback) => {
    console.log("hai");
    AWS.config.update({region: 'us-west-2'});
    var params = {
      endTime: 1553686248, /* required */
      logGroupName: '/aws/lambda/tset', /* required */
      queryString: 'fields  @message| filter @message like /START/| fields strcontains(@message, "$LATEST") as @CONTAINS_ap | stats sum(@CONTAINS_ap) as @sample',
      startTime: 1553538648,
      limit: 0
    };
      cloudwatchlogs.startQuery(params, function(err, data) {
      if (err) console.log(err, err.stack); // an error occurred
      else     console.log(data);           // successful response
    });
}
4

1 回答 1

2

您使用的是什么版本的“aws-sdk”?StartQuery 已添加到2.364.0https ://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md#23640

于 2019-03-29T07:17:28.477 回答