simple-graphite-client v0.2.8
simple-graphite-client
This is a compact TypeScript library designed for transmitting data to a Graphite metrics server (Carbon). It draws significant inspiration from graphyte, a Python library. Currently, this library is simpler in comparison, as additional complexity wasn't required at this stage.
npm install simple-graphite-clientUsage
You first have to define the Graphite client:
import Sender from "simple-graphite-client";
const client = new Sender({
host: "http://graphite.example.org"
});
await client.send({
metric: "foo.bar",
value: 42
});If you want to send tagged metrics, the usage is as follows:
await client.send({
metric: "foo.bar",
value: 42,
tags: {"ding": "dong"}
});If you want to send via UDP instead of TCP, just change protocol:'udp' to Sender() call.
License
Licensed under the MIT license.
Development
NVM - Node Version Manager
I recommend you to use nvm to download the current version of node.js used on the project.
To download the nvm run the follow command:
You can look for more information on the nvm repository
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bashOnce you have installed nvm and it's working, you can run the follow to install the correct version of node.js:
Make sure you are on the current path of the project, where the .nvmrc file is located
nvm installnvm useInstalling packages
Once you have installed the current version of Node.js, NPM you can do it running the follow:
Make sure you are using the current context of Node.js and NPM.
npm installTest Dependencies
To run the tests you'll need to have tcp-receiver running on port 9950 and 9528.
To do that, run:
docker run -d -p 9950:9950 -p 9528:9528 cameritelabs/tcp-receiver:latestOnce you have the container running you can run:
# to run the tests
npm run test
# to run the tests and generate coverage report
npm run coverage