docs
process metrics
By plugging process metrics onto your code, you will be able to monitor in-code values, in realtime.
types
eg. Monitor variable value
var io = require('@pm2/io')
// Here the value function will be called each second to get the value
var metric = io.metric({
name : 'Realtime user',
value : function() {
return Object.keys(users).length
}
})
// Here we are going to call valvar.set() to set the new value
var valvar = io.metric({
name : 'Realtime Value'
})
valvar.set(23)
// Here the value function will be called each second to get the value
var metric = io.metric({
name : 'Realtime user',
value : function() {
return Object.keys(users).length
}
})
// Here we are going to call valvar.set() to set the new value
var valvar = io.metric({
name : 'Realtime Value'
})
valvar.set(23)
eg. Downloads being processed, user connected
var io = require('@pm2/io')
var http = require('http')
var counter = io.counter({
name : 'Active requests'
})
http.createServer(function (req, res) {
counter.inc()
req.on('end', function() {
// Decrement the counter, counter will eq 0
counter.dec()
})
res.writeHead(200, {'Content-Type': 'text/plain'})
res.write('Hello World!')
res.end()
}).listen(6001)
var http = require('http')
var counter = io.counter({
name : 'Active requests'
})
http.createServer(function (req, res) {
counter.inc()
req.on('end', function() {
// Decrement the counter, counter will eq 0
counter.dec()
})
res.writeHead(200, {'Content-Type': 'text/plain'})
res.write('Hello World!')
res.end()
}).listen(6001)