1.2.2 • Published 6 years ago

pm2-cluster-prometheus v1.2.2

Weekly downloads
19
License
MIT
Repository
github
Last release
6 years ago

pm2-cluster-prometheus

PM2 module to aggregate node.js workers' metrics when use pm2 cluster mode

Install

$ pm2 install pm2-cluster-prometheus

Configuration

Default settings:

  "config": {
    "app_name": "api",             //需要拉取监控数据的 APP 名称
    "app_group": "book",           //consul 服务分组 
    "port": 3000,                  //http服务默认端口,提供 /metrics 和 /online 接口
    "reigster_disabled": false,    //是否禁止服务注册到 consul
    "consul_host": "127.0.0.1",    
    "consul_port": "8500",
    "register_mode": "cluster"            // default:cluster   other: worker
  }

To modify the config values you can use the following commands:

pm2 set pm2-cluster-prometheus:app_name hello
pm2 set pm2-cluster-prometheus:port 4000

Mode

"register_mode": "cluster" get metrics from http://localhost:3000/metrics

"register_mode": "worker" get each worker metrics from http://localhost:3000/metrics?pm_id=1

Node.js APP

// prom-client version require >= 11.0.0
const promClient = require('prom-client')

process.on('message', function (message) {
    if (message.type === 'prom:getMetricsReq') {
        process.send({
            type: 'prom:getMetricsRes',
            data: {
                requestId: message.data.requestId,
                metrics: promClient.register.getMetricsAsJSON()
            }
        })
    }
})

Uninstall

$ pm2 uninstall pm2-cluster-prometheus

License

MIT

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago