Loading...

Elasticsearch Reporter for Dropwizard Metrics

This post describes how to export Dropwizard Metrics to elasticsearch. Instead of using logstash to parse application log files, the metrics can be exported directly within any Java application. This plugin is maintained by elastic.co.

See https://github.com/elastic/elasticsearch-metrics-reporter-java. For the impatient: Add to your pom.xml

<dependency>
  <groupId>org.elasticsearch</groupId>
  <artifactId>metrics-elasticsearch-reporter</artifactId>
  <version>2.2.0</version>
</dependency>

Start reporting to elasticsearch cluster e.g. in main()

ElasticsearchReporter reporter = ElasticsearchReporter
    .forRegistry(registry())
    .hosts("elasticsearch-node1:9200", "elasticsearch-node2:9200")
    .index("metrics")
    .indexDateFormat(null) //no date suffix
    .build();
reporter.start(10, TimeUnit.SECONDS);