Graphite UDP client for Node.js
npm install graphite-service
var Graphite = require('graphite-service')
var metric = new Graphite([options])
metric.add(name, value, type)
options
is an object with the following defaults:
{
host: 'localhost', // graphite server host or ip
port: 8081, // graphite server udp port
type: 'udp4', // udp type (udp4 or udp6)
prefix: '', // a prefix to prepend to the name of all metrics
suffix: '', // a suffix to append to the name of all metrics
interval: 5000, // group metrics for 5s and send only 1 request
allow: {
production: true,
development: false
}
}
var Graphite = require('graphite-service')
var metric = new Graphite({
prefix: 'app',
interval: 10000
})
metric.add('user', 1, 'c') // add 1
Will generate
app.user 1 1447192345
add new instance graphite-service
var userMetric = metric.instance();
userMetric.add('metric', 1, 'c');
add time metric
var userMetric = metric.instance();
userMetric.start('metric');
....
userMetric.end('metric');
Will generate
app.metric:time|s;
During the interval
time option, if 2 or more metrics with the same name
are sent, metrics will be added (summed)
metric.add('metric', 1)
Will generate
app.metric 1 1447192345;
Licensed under the MIT license.