graphite
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/graphite package

0.1.5 • Public • Published

graphite

Node.js CI

A node.js client for graphite.

Install

npm install graphite

Usage

You first have to define the Graphite client:

var graphite = require('graphite');
var client = graphite.createClient('plaintext://graphite.example.org:2003/');

You can send metrics without a timestamp. The current Unix epoch will then be used in place:

var metrics = {foo: 23};
client.write(metrics, function(err) {
  // if err is null, your data was sent to graphite!
});

If you wish to set your own timestamp, you must use Date.now() (millisecond precision) as parameter and not Math.floor(Date.now() / 1000) (second precision), otherwise your metrics will probably get ignored by Graphite:

var metrics = {foo: 23};
var timestamp = Date.now();
client.write(metrics, timestamp, function(err) {
  // if err is null, your data was sent to graphite!
});

In Graphite 1.1.1 (21.12.17), tagging becomes available. You can send tagged metrics as follows:

var metrics = {foo: 23};
var tags = {'name': 'foo.bar', 'some.fancy.tag': 'somefancyvalue'};
client.writeTagged(metrics, tags, function(err) {
  // if err is null, your data was sent to graphite!
});

Todo

  • More docs

License

Licensed under the MIT license.

Readme

Keywords

none

Package Sidebar

Install

npm i graphite

Weekly Downloads

6,637

Version

0.1.5

License

none

Unpacked Size

17.9 kB

Total Files

19

Last publish

Collaborators

  • felixge
  • serphentas