metrics-opentsdb

metrics reporter for OpenTSDB

License

License

Categories

Categories

Metrics Application Testing & Monitoring Monitoring
GroupId

GroupId

com.github.sps.metrics
ArtifactId

ArtifactId

metrics-opentsdb
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

metrics-opentsdb
metrics reporter for OpenTSDB
Project URL

Project URL

http://github.com/sps/metrics-opentsdb
Source Code Management

Source Code Management

http://github.com/sps/metrics-opentsdb/

Download metrics-opentsdb

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.sps.metrics/metrics-opentsdb/ -->
<dependency>
    <groupId>com.github.sps.metrics</groupId>
    <artifactId>metrics-opentsdb</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.sps.metrics/metrics-opentsdb/
implementation 'com.github.sps.metrics:metrics-opentsdb:1.1.0'
// https://jarcasting.com/artifacts/com.github.sps.metrics/metrics-opentsdb/
implementation ("com.github.sps.metrics:metrics-opentsdb:1.1.0")
'com.github.sps.metrics:metrics-opentsdb:jar:1.1.0'
<dependency org="com.github.sps.metrics" name="metrics-opentsdb" rev="1.1.0">
  <artifact name="metrics-opentsdb" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.sps.metrics', module='metrics-opentsdb', version='1.1.0')
)
libraryDependencies += "com.github.sps.metrics" % "metrics-opentsdb" % "1.1.0"
[com.github.sps.metrics/metrics-opentsdb "1.1.0"]

Dependencies

compile (3)

Group / Artifact Type Version
io.dropwizard.metrics : metrics-core jar 3.1.0
org.glassfish.jersey.core : jersey-client jar 2.22.2
org.glassfish.jersey.media : jersey-media-json-jackson jar 2.22.2

test (3)

Group / Artifact Type Version
junit : junit jar 4.12
org.mockito : mockito-core jar 1.10.17
org.slf4j : slf4j-simple jar 1.7.5

Project Modules

There are no modules declared in this project.

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

Versions

Version
1.1.0
1.0.8
1.0.7
1.0.4
1.0.3
1.0.2