Git Product home page Git Product logo

metrics-opentsdb's Introduction

Metrics OpenTSDB Build Status Coverage Status

A Coda Hale Metrics Reporter.

OpenTsdbReporter allows your application to constantly stream metric values to an opentsdb server via the 2.0 HTTP API or the Telnet API.

This reporter also supports per-metric tags in addition to a global set of tags.

Example Usage

dropwizard 3.0.1 app:

@Override
public void run(T configuration, Environment environment) throws Exception {
...
    OpenTsdb opentsdb = OpenTsdb.forService("http://opentsdb/")
                                      .withGzipEnabled(true) // optional: compress requests to tsd
                                      .create();

    OpenTsdbReporter.forRegistry(environment.metrics())
                    .prefixedWith(environment.getName())
                    .withTags(ImmutableMap.of("other", "tags")) // static tags included with every metric
                    // .withBatchSize(10) // optional batching. unbounded by default. likely need to tune this.
                    .build(opentsdb)
                    .start(15L, TimeUnit.SECONDS); // tune your reporting interval

Tagged Metric Registry

// setup
TaggedMetricRegistry metrics = new TaggedMetricRegistry();
Map<String, String> tags = new HashMap<String, String>();
tags.put("host", "localhost");
tags.put("foo", "bar");

OpenTsdbReporter.forRegistry(metrics)
    .withTags(tags)
    .withBatchSize(5)
	.build(OpenTsdb.forService("http://opentsdb/")
	.create())
	.start(30L, TimeUnit.SECONDS);

// using metric with tags
Map<String, String> counterTags = new HashMap<String, String>(tags);
counterTags.put("trigger", trigger);

TaggedCounter counter = metrics.taggedCounter("my.tagged.counter", counterTags);
counter.inc();
  • Completely backwords compatible with existing Coda Hale metrics
  • All Coda Hale metrics have a Tagged<metric> counterpart (e.g. TaggedCounter, TaggedMeter, etc.)
  • Registry can have default tags that can be overridden at the metric level
  • Metrics can have additional tags not in the registry
  • Calling a tagged<metric> function (e.g. taggedCounter(), taggedMeter(), etc.) on the TaggedMetric registry will perform a get or create operation. If the same type of metric with the same name and tags is already registered in the registry, it will be returned, otherwise it will be created and returned. There is no need to check for name or tag collisions.

The Telnet API is identical to the above, except with

OpenTsdbTelnet.forService("mycollector.example.com", 4243)

For per-metric tags, encode the tags into the metric name using

Map<String, String> myCounterTags;
String name = OpenTsdbMetric.encodeTagsInName('mycounter', myCounterTags);

metrics-opentsdb's People

Contributors

cbakersdl avatar cnbaker avatar jamesshao14 avatar kmax avatar rbuck23 avatar sps avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.