Code Monkey home page Code Monkey logo

metrics-elasticsearch's Introduction

metrics-elasticsearch

Kibana-friendly Transport and HTTP Elasticsearch reporters for Dropwizard Metrics

Versions

If using the HTTP API, any version of Elasticsearch that supports the Bulk API will report fine using any version of metrics-elasticsearch.

However, if using the Transport API, please note that metrics-elasticsearch uses a specific version of Elasticsearch noted in the table below.

metrics-elasticsearch dropwizard metrics elasticsearch
1.0.0 3.1.0 1.2.4
1.0.1 3.1.1 1.2.4
1.1.0 3.1.1 1.3.9

## Usage

Setting up Maven & Gradle

Reporters

The Dropwizard Metrics user guide documents how to set up the metrics registry and create different types of metrics.

This library provides two different methods to report to Elasticsearch; using the HTTP API and using the Transport API.

HTTP Reporter

The following will create a reporter that uses an already initialised Metric Registry, sets the indexes generated as "test-YYYY.MM.DD" and reports over HTTP to localhost:9201.

ElasticsearchReporter reporter = ElasticsearchHttpReporter
                .forRegistryAndIndexPrefix(registry, "test")
                .build("localhost:9201");
reporter.start(1, TimeUnit.SECONDS);

The reporter above is created with default values. You can change how the metrics are reported using further options like the example below.

ElasticsearchReporter reporter = ElasticsearchHttpReporter
                .forRegistryAndIndexPrefix(registry, "test")
                .withTimestampFieldName("@timeywimey")
                .withClock(Clock.defaultClock()).prefixedWith("metric-name-prefix-")
                .convertRatesTo(TimeUnit.SECONDS)
                .convertDurationsTo(TimeUnit.MILLISECONDS)
                .withBulkRequestLimit(10).filter(MetricFilter.ALL)
                .build("localhost:9201");
reporter.start(1, TimeUnit.SECONDS);

Transport Reporter

The following will create a reporter that uses an already initialised Metric Registry, sets the indexes generated as "test-YYYY.MM.DD" and reports over the Transport API using an Elasticsearch client instance.

ElasticsearchReporter reporter = ElasticsearchTransportReporter
                .forRegistryAndIndexPrefix(registry, "test")
                .build(client);
reporter.start(1, TimeUnit.SECONDS);

The reporter above is created with default values. You can change how the metrics are reported using further options like the example below.

ElasticsearchReporter reporter = ElasticsearchTransportReporter
                .forRegistryAndIndexPrefix(registry, "test")
                .withTimestampFieldName("@timeywimey")
                .withClock(Clock.defaultClock()).prefixedWith("metric-name-prefix-")
                .convertRatesTo(TimeUnit.SECONDS)
                .convertDurationsTo(TimeUnit.MILLISECONDS)
                .withBulkRequestLimit(10).filter(MetricFilter.ALL)
                .build(client);
reporter.start(1, TimeUnit.SECONDS);

## Data Format

The data will be inserted under the specified index suffixed with the year, month and day (YYYY.MM.DD). The type used is the metric type (e.g. guage, histrogram, meter, etc.). Each document inserted into Elasticsearch will have its ID generated by Elasticsearch. The document itself stores the timestamp, metric name and metric values.

metrics-elasticsearch's People

Contributors

tomcashman avatar

Watchers

James Cloos 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.