pm2-graphite

0.0.1 • Public • Published

pm2-graphite

Build Status Coverage Status npm version npm downloads Gitter chat

PM2 graphite sender module to send aggregated metrics. If you send messages from cluster of PM2, pm2-graphite will aggregate and send them to graphite server.

Usage

Installation

$ pm2 install pm2-graphite
$ pm2 set pm2-graphite:interval 30000 # Default: 10000(ms) 
# with configurtaion file 
$ pm2 set pm2-graphite:path /absolute/path/of/the/configuration/file
# with pm2 configurtaion 
$ pm2 set pm2-graphite:host my.graphite.host.com #target graphite host 
$ pm2 set pm2-graphite:port 2003 #target graphite port 

Configuration File Format

{
  "graphite": {
    "host": "my.graphite.host.com",
    "port": 2003
  }
}

PM2 Application Configuration (app.json)

For now, PM2-Graphite Only Support cluster mode.

{
  "apps": [
    {
      "name": "app_name",
      "...": "...",
      "exec_mode": "cluster"
    }
  ]
}

Send message from cluster to pm2-graphite

 
const metrics = {
  'app_name.$id.metricsName': metricsValue // String `$id` will replaced to app id of PM2. (Only first appeared string)
  'app_name.$id.requestCounts': 10000 // Example
};
process.send && process.send({ metrics });
 

Metrics which would be sent to graphite

{
    "app_name.1.requestCounts" : 100,
    "app_name.1.errorCounts" : 10,
    "app_name.2.requestCounts" : 100,
    "app_name.2.errorCounts" : 10,
    "app_name.3.requestCounts" : 100,
    "app_name.3.errorCounts" : 10,
    "app_name.4.requestCounts" : 100,
    "app_name.4.errorCounts" : 10
}

Monyt

If you use Monyt with its ProcessSender, you could make metrics to send easily.

Package Sidebar

Install

npm i pm2-graphite

Weekly Downloads

2

Version

0.0.1

License

MIT

Last publish

Collaborators

  • mrnoname