简体   繁体   English

使用 Node.JS 监控 AWS Api 网关

[英]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.

相关问题 使用 node.js 从 AWS Lambda 将自定义错误传回 AWS API Gateway - Passing custom errors back to AWS API Gateway from AWS Lambda using node.js AWS Lambda 与 API 网关和 Node.js 返回 HTTP 50 - AWS Lambda with API gateway and Node.js returning HTTP 502 如何使用无服务器框架通过 AWS API 网关在 Node.js 中编写的 AWS Lambda function 上返回错误? - How do I return errors on an AWS Lambda function written in Node.js through the AWS API Gateway using the Serverless framework? AWS API 网关与 Lambda HTTP GET 请求(Node.js)502 错误网关 - AWS API Gateway with Lambda HTTP GET Request (Node.js) 502 Bad Gateway Node.js AWS EC2上的RESTful API服务器与AWS API网关 - Node.js RESTful API server on AWS EC2 vs AWS API Gateway 如何使用Javascript(Node.js)读取通过Http Post发送的变量值并在AWS API Gateway Lambda上获取? - How to read variable value sent over Http Post and Get on AWS API Gateway Lambda using Javascript(Node.js)? node.js的API网关示例 - API Gateway example for node.js AWS Lambda/API 网关 - 传递 ID 以使用 node.js 在 mysql 中删除一行 - AWS Lambda/API Gateway - Pass an ID to delete a row in mysql with node.js AWS + API网关+ Lambda + Node.js在Google上的操作ApiAiApp - AWS + API Gateway + Lambda + Node.js actions-on-google ApiAiApp 使用AWS Lambda和Node.js在API端点上显示图像 - Displaying an image on API endpoint using aws lambda and node.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM