Skip to content

redcrazyheart/graphite-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

graphite-services

Graphite UDP client for Node.js

Install

npm install graphite-service

Usage

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
  }
}

Example

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

API

metric.instance

add new instance graphite-service

var userMetric = metric.instance();
userMetric.add('metric', 1, 'c');

metric.start & metric.end

add time metric

var userMetric = metric.instance();
userMetric.start('metric');
....
userMetric.end('metric');

Will generate

app.metric:time|s;

metric.add

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;

License

Licensed under the MIT license.

About

graphite-services

Resources

Stars

Watchers

Forks

Packages

No packages published