[英]Monitoring AWS Api Gateway Using Node.JS
I want to monitoring "How many api call on AWS API GATEWAY".我想监控“AWS API GATEWAY 上有多少 api 调用”。
I can monitoring API call using "Usage Plans" on AWS console.我可以使用 AWS 控制台上的“使用计划”监控 API 调用。 Usage Plans => Select Plans => API Keys => Select API Key => Click Usage.使用计划 => Select 计划 => API 密钥 => Select ZDB974238714CA8DE634A7CED 密钥 =>点击使用。
How implement it using node.js?如何使用 node.js 实现它?
From Amazon API Gateway Dimensions and Metrics - Amazon API Gateway :从Amazon API 网关维度和指标 - Amazon API 网关:
Count
: The total number API requests in a given period.Count
:给定时间段内 API 请求的总数。
So, you can obtain this information directly out of Amazon CloudWatch .因此,您可以直接从Amazon CloudWatch获取此信息。
Solved.解决了。 This is the code for get API call count.这是获取 API 调用计数的代码。
var AWS = require('aws-sdk');
var apigateway = new AWS.APIGateway({
apigateway: '2015-07-09',
accessKeyId: '',
secretAccessKey: '',
region: '',
});
var params = {
endDate: '', /* required */
startDate: '', /* required */
usagePlanId: '', /* required */
keyId: '',
};
apigateway.getUsage(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
Source: AWSJavaScriptSDK来源: AWSJavaScriptSDK
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.