node-heap-gc-cloudwatch

2.2.0 • Public • Published

Build Status NPM version NPM dependencies NSP Status

node-heap-gc-cloudwatch

Send v8 heap statistics and garbage collection statistics to CloudWatch.

CloudWatch heap space used size graph

Getting started

Install the module:

npm install node-heap-gc-cloudwatch

In your app, create and start an agent:

var config = {};
require("node-heap-gc-cloudwatch")(config, function(err, agent) {
  if (err) {
    throw err;
  } else {
    agent.on("error", function(err) {
      console.log("error", err);
    });
    agent.start(function(err) {
      if (err) {
        throw err;
      } else {
        console.log("started");
      }
    });
  }
});

After ~1 minute you will see the first metrics in CloudWatch under the node name space.

Make sure to allow the cloudwatch:PutMetricData Action in your IAM policy.

Configuration

  • collectInterval: Number - Collect new heap statistics every collectInterval ms (default 1000)
  • writeInterval: Number - Send metric to CloudWatch every writeInterval ms (default 60000)
  • heapStatistics: Array[String] - Values to report to CloudWatch from v8.getHeapStatistics() (default ["total_heap_size", "total_heap_size_executable", "total_physical_size", "total_available_size", "used_heap_size", "heap_size_limit"])
  • heapSpaceStatistics: Array[String] - Values to report to CloudWatch from v8.getHeapSpaceStatistics() (default ["space_size", "space_used_size", "space_available_size", "physical_space_size"])
  • cloudwatch: AWS.CloudWatch - CloudWatch service object (default new AWS.CloudWatch())
  • namespace: String - The namespace for the metric data (default node)
  • dimensions: Object[String, String] - Add additional dimensions like {Application: "webshop", Environment: "production"}. (default {})
  • addProcessIdDimension: Boolean - If true, adds the ProcessId dimension with the value of process.pid (default false)
  • addInstanceIdDimension: Boolean - If true, adds the InstanceId dimension with the value of the EC2 instance id (default false)
  • omitGCPauseMetrics: Boolean - If true, omits the gc_pause metrics (default false)

Important

CloudWatch treats each unique combination of dimensions as a separate metric. For information on how this affects pricing, see the Amazon CloudWatch product information page.

Readme

Keywords

Package Sidebar

Install

npm i node-heap-gc-cloudwatch

Weekly Downloads

8

Version

2.2.0

License

MIT

Unpacked Size

77 kB

Total Files

10

Last publish

Collaborators

  • hellomichibye