Git Product home page Git Product logo

cloudwatch-nodejs-plugin's Introduction

cloudwatch-nodejs-plugin

This plugin is a modification of heroku nodejs plugin. Its purpose is to send NodeJS monitoring data such as event loop delays, event loop usage, GC metrics to AWS CloudWatch.

How does it work?

You can see most of the implementation details in src/nativeStats.cc. The plugin sets callbacks around GC invocations, and during the prepare and check phases of the event loop, tracks the amount of time spent in each.

This data is exposed to a JS loop that periodically sends data to AWS CloudWatch.

Debugging

If the plugin is not working for you once, the first thing you should do is set the ENV var NODE_DEBUG to monitor. By default all logging from the plugin is silenced. If you want to see the actual values sent to CloudWatch, set NODE_DEBUG to monitor-debug

$ NODE_DEBUG=monitor,monitor-debug node -r cloudwatch-nodejs-plugin myapp.js

Metrics collected

{
  GcCollections: 748,
  GcPause: 92179.835,
  GcOldCollections: 2,
  GcOldPause: 671.054,
  GcYoungCollections: 746,
  GcYoungPause: 91508781,
  EventLoopUsage: 12%,
  EventLoopDelay: [array of delays]
}

Development

You can collect and print out metrics locally by running in debug mode.

You can run develop this locally by running build:

$ npm run build

and including the built module in another local Node app like:

$ NODE_OPTIONS="--require {{ working directory }}/cloudwatch-nodejs-plugin/cloudwatch-nodejs-plugin" AWS_METRICS_NAMESPACE="MyApp" node src/index.js

Example app with periodic event loop and gc activity: https://github.com/heroku/node-metrics-single-process

Usage

Require the plugin directly or via NODE_OPTIONS variable. AWS_METRICS_NAMESPACE should be set. You can optionally set METRICS_INTERVAL_OVERRIDE to control the frequency of snapshots.

cloudwatch-nodejs-plugin's People

Contributors

danielleadams avatar dependabot[bot] avatar edmorley avatar jmorrell avatar snyk-bot avatar svyatogor avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.