Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/felixge/node-graphite
A node.js client for graphite.
https://github.com/felixge/node-graphite
Last synced: about 8 hours ago
JSON representation
A node.js client for graphite.
- Host: GitHub
- URL: https://github.com/felixge/node-graphite
- Owner: felixge
- Created: 2011-10-31T09:31:51.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2023-10-19T15:54:41.000Z (about 1 year ago)
- Last Synced: 2024-12-17T01:09:45.767Z (8 days ago)
- Language: JavaScript
- Homepage:
- Size: 40 KB
- Stars: 105
- Watchers: 5
- Forks: 16
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# graphite
[![Node.js CI](https://github.com/felixge/node-graphite/actions/workflows/node.js.yml/badge.svg)](https://github.com/felixge/node-graphite/actions/workflows/node.js.yml)
A node.js client for graphite.
## Install
```
npm install graphite
```## Usage
You first have to define the Graphite client:
```js
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:
```js
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:
```js
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)](http://graphite.readthedocs.io/en/latest/releases/1_1_1.html), [tagging](http://graphite.readthedocs.io/en/latest/tags.html) becomes available. You can send tagged metrics as follows:
```js
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.