无法调用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
});
}
答案 0 :(得分:2)
您使用的是哪个版本的“ aws-sdk”?在2.364.0
中添加了StartQuery:https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md#23640