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.
<dependency> <groupId>com.addthis.metrics</groupId> <artifactId>reporter-config</artifactId> <version>2.0.5</version> </dependency>
Current supported reporters include:
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
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
loadFromFile() if you
aren't into validating), and then
In addition to an inline list, the ganglia config supports
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
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$"
Assuming you have Apache Maven installed and configured:
And you should be all set.
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.
Where People Hang Out
Main Metrics mailing list: http://groups.google.com/group/metrics-user