The smarthings-2.1.0.x branch is used to modify this library in a way so that we can replace the version of it in the cassandra classpath and then leverage our cassandra-datadog.
Coda Hale's Metrics package makes it easy to create useful metrics so you know what is going on in production. In addition to showing up in the normal Java places (JMX), Metrics supports an arbitrary number of Reporters (where to send the application telemetry to make pretty graphs). Ganglia and Graphite (or both!) are among the most popular choices.
However, Metrics purposefully doesn't come with a kitchen sink of support for every dependency injection or configuration tool yet devised by Java developers. Metrics-Reporter-Config aims to provide a simple way to configure and enable a set of Reporters that can be shared among applications. It should fit most (say 90% of) use cases and avoid situations like a plethora of subtly incompatible properties files.
In particular, it should seamlessly fit into Dropwizard service Configuration classes.
<dependency>
<groupId>com.addthis.metrics</groupId>
<artifactId>reporter-config</artifactId>
<version>2.0.5</version>
</dependency>
Current supported reporters include:
- console
- csv
- ganglia
- graphite
Note that Metrics-Reporter-Config's dependencies on non-core reporters
are optional in maven-speak. That means that depending on
Metrics-Reporter-Config should not pull in "a bunch of junk", but your
applications will need to explicitly depend on the reporters they want
(such as metrics-ganglia
).
An example config file might look like this:
csv:
-
outdir: '/tmp/metrics/crazy-debugging'
period: 2
timeunit: 'MINUTES'
ganglia:
-
period: 60
timeunit: 'SECONDS'
hosts:
- host: 'gmond.domain.local'
port: 8649
- host: 'gmond-backup.domain.local'
port: 8649
graphite:
-
period: 120
timeunit: 'SECONDS'
hosts:
- host: 'graphite-server.domain.local'
port: 2003
And then to wire up your app call
ReporterConfig.loadFromFileAndValidate()
(or loadFromFile()
if you
aren't into validating), and then enableAll()
.
In addition to an inline list, the ganglia config supports gmondConf
field which tells it where to find gmond's config file (ie
/etc/ganglia/gmond.conf
) and read any UDP send channels there. This
should make it easy to keep the java app config and the rest of the
system in sync.
Just add a ReporterConfig
instance to your app's
Configuration
class. Metrics-Reporter-Config uses the same validation
implementation as dropwizard. You will still need to call an enable
method when initialization your app.
predicate:
color: "black"
patterns:
- ".*JMXONLY$"
Each reporter can have a simple name based predicate with a white or black list of regular expressions. Use this for rarely used metrics that will only show up in JMX without flooding ganglia with 20k extra metrics. In practice our configurations tend to look like this:
ganglia:
-
period: 60
timeunit: 'SECONDS'
gmondConf: '/etc/ganglia/gmond.conf'
predicate:
color: "black"
patterns:
- ".*JMXONLY$"
By default predicates operate on the "Metric Name" (usually something
like MyClass
). If you want to operable on the conventional "full"
name (org.example.foo.MyClass
) enable useQualifiedName
.
Assuming you have Apache Maven installed and configured:
mvn package
And you should be all set.
To run individual tests use -Dtest=
and
-Dorg.slf4j.simpleLogger.defaultLogLevel=
to change the test log
level.
It's x.y.z where:
- x: compatible Metrics major version
- y: next release
- z: bug fix only
Metrics-Reporter-Config is released under the Apache License Version 2.0. See Apache or the LICENSE file in this distribution for details.
Main Metrics mailing list: http://groups.google.com/group/metrics-user