lorenwest / monitor-dashboard

Dashboards for the Node.js monitor project
https://lorenwest.github.com/monitor-dashboard
MIT License
204 stars 28 forks source link

the value of stat increment doesn't change #22

Open hossamr77 opened 9 years ago

hossamr77 commented 9 years ago

i have created the following listener and registered it when the server is starting to listen to the event of stat.increment and log the value into the console but unfortunately the value is always 1

listener.js

var statMonitor = require('monitor').Stat;

exports.InitListeners = function() { statMonitor.on('*', function myListenerFunction(module, name, value, type) { console.log('module: ' + module + ' stat: ' + name + ' value: ' + value + ' type: '+type);

}); }

and here is calling of stat increment var stat = require('monitor').getStatLogger('products');

function getProducts(opts, req, res, callback){ stat.increment('retriveProducts'); }

and here the log

module: products stat: retriveProducts value: 1 type: c

lorenwest commented 9 years ago

That looks right. Your console log is showing the amount that the counter is being incremented by.

hossamr77 commented 9 years ago

but i need to show the value of stat variable (retriveProducts ) not the amount that the counter is being incremented by.

lorenwest commented 9 years ago

Then you want a gauge, not a counter.

hossamr77 commented 9 years ago

let me describe what i want to do , i'd like to display how many times certain function has been invoked.

FYI:i used gauge and the same thing module: promotion stat: retriveFeaturedProducts value: 1 type: g

lorenwest commented 9 years ago

It sounds like you want a counter, and a backend that keeps track of the counts. The only way I know how to do this is to connect it with graphite or another backend that aggregates your counts. If you're working with multiple servers, graphite is the backend to use.