Typescript Metrics Reporter for graphite carbon.
This library is made for inspector-metrics node module and
is meant to be used with nodejs
.
It uses node-graphite as graphite/carbon client.
npm install --save inspector-carbon
import { MetricRegistry } from "inspector-metrics";
import { CarbonMetricReporter } from "inspector-carbon";
// instance the carbon reporter
const reporter: CarbonMetricReporter = new CarbonMetricReporter({
host: "http://graphite-server/",
});
const registry: MetricRegistry = new MetricRegistry();
// add the registry to the reporter
reporter.addMetricRegistry(registry);
// start reporting
await reporter.start();
import { MetricRegistry } from "inspector-metrics";
import { CarbonMetricReporter } from "inspector-carbon";
// instance the carbon reporter
const reporter: CarbonMetricReporter = new CarbonMetricReporter({
host: "http://graphite-server/",
});
// set common tags for all metrics
reporter.getTags().set("app-name", "my-service");
reporter.getTags().set("app-version", "v1.2.3");
import { Event, MetricRegistry } from "inspector-metrics";
import { CarbonMetricReporter } from "inspector-carbon";
// instance the carbon reporter
const reporter: CarbonMetricReporter = new CarbonMetricReporter({
host: "http://graphite-server/",
});
// build an ad-hoc event
const event = new Event<number>("application_started")
.setValue(1.0)
.setTag("mode", "test")
.setTag("customTag", "specialValue");
// send the event to graphite
reporter.reportEvent(event);
To use the playground you need to have docker
and docker-compose
installed.
# boots all services (graphite / grafana) and provisions the example dashboard
test-env/boot.sh
# running playground script
./playground.sh
http://localhost:3000