# node-heap-gc-cloudwatch

> Report v8 heap usage and gc activity to CloudWatch

Latest version **2.2.0** (published 2020-12-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-heap-gc-cloudwatch
pnpm add node-heap-gc-cloudwatch
yarn add node-heap-gc-cloudwatch
bun add node-heap-gc-cloudwatch
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2020-12-23 |
| First published | 2016-03-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 4 |
| Unpacked size | 75.2 KB |
| Known vulnerabilities | 0 (+3 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Michael Wittig |
| Maintainers | hellomichibye |
| Keywords | heap, gc, v8, CloudWatch |

## Links

- npm: https://www.npmjs.com/package/node-heap-gc-cloudwatch
- Repository: https://github.com/michaelwittig/node-heap-gc-cloudwatch
- Homepage: https://github.com/michaelwittig/node-heap-gc-cloudwatch#readme
- Issues: https://github.com/michaelwittig/node-heap-gc-cloudwatch/issues
- npm.io page: https://npm.io/package/node-heap-gc-cloudwatch

## Dependencies (4)

- [merge](https://npm.io/package/merge.md) 1.2.1
- [aws-sdk](https://npm.io/package/aws-sdk.md) 2.635.0
- [gc-stats](https://npm.io/package/gc-stats.md) 1.4.0
- [neo-async](https://npm.io/package/neo-async.md) 2.6.1

## Recent versions

- 2.2.0 (latest) — 2020-12-23
- 2.1.0 — 2020-03-09
- 2.0.0 — 2018-11-20
- 1.1.1 — 2017-12-29
- 1.1.0 — 2016-03-09
- 1.0.0 — 2016-03-09

## README

[![Build Status](https://secure.travis-ci.org/michaelwittig/node-heap-gc-cloudwatch.png)](http://travis-ci.org/michaelwittig/node-heap-gc-cloudwatch)
[![NPM version](https://badge.fury.io/js/node-heap-gc-cloudwatch.png)](http://badge.fury.io/js/node-heap-gc-cloudwatch)
[![NPM dependencies](https://david-dm.org/michaelwittig/node-heap-gc-cloudwatch.png)](https://david-dm.org/michaelwittig/node-heap-gc-cloudwatch)
[![NSP Status](https://nodesecurity.io/orgs/michaelwittig/projects/62bc62e9-d4e2-42f8-9b38-25b530faf791/badge)](https://nodesecurity.io/orgs/michaelwittig/projects/62bc62e9-d4e2-42f8-9b38-25b530faf791)

# node-heap-gc-cloudwatch

Send v8 heap statistics and garbage collection statistics to CloudWatch.

![CloudWatch heap space used size graph](./graph.png?raw=true "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:

```javascript
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()](https://nodejs.org/api/v8.html#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()](https://nodejs.org/api/v8.html#v8_getheapspacestatistics) (default `["space_size", "space_used_size", "space_available_size", "physical_space_size"]`)
* `cloudwatch`: [AWS.CloudWatch](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatch.html#constructor-property) - 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](http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/cloudwatch_concepts.html#Dimension). For information on how this affects pricing, see the Amazon CloudWatch product information page.

---
_Source: https://npm.io/package/node-heap-gc-cloudwatch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
