Harles Bayu Anggara
Harles Bayu Anggara

Reputation: 19

Monitoring AWS Api Gateway Using Node.JS

I want to monitoring "How many api call on AWS API GATEWAY".

I can monitoring API call using "Usage Plans" on AWS console. Usage Plans => Select Plans => API Keys => Select API Key => Click Usage.

How implement it using node.js?

Upvotes: 0

Views: 302

Answers (2)

Harles Bayu Anggara
Harles Bayu Anggara

Reputation: 19

Solved. This is the code for get API call count.

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

Upvotes: 0

John Rotenstein
John Rotenstein

Reputation: 269550

From Amazon API Gateway Dimensions and Metrics - Amazon API Gateway:

Count: The total number API requests in a given period.

So, you can obtain this information directly out of Amazon CloudWatch.

Upvotes: 1

Related Questions