inspector-carbon

Typescript Metrics Reporter for graphite carbon.

NPM Version License Build Status Dependencies Status

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.

install

npm install --save inspector-carbon

basic usage

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();

set common tags for all metrics

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");

reporting events

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);

dev

using the playground

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

view data in grafana

  1. Navigate to http://localhost:3000
  2. select example dashboard (upper left corner: "Home") "Graphite / Carbon example Dashboard"

Example Dashboard

License

MIT

result-matching ""

    No results matching ""