Code Monkey home page Code Monkey logo

jmx-dropwizard-metrics's Introduction

jmx-dropwizard-metrics Clojars Project

When to Use ?

Ans: If you are using dropwizard and publishing the metrics from MetricRegistry instead of JMX.

Since most of the open source libraries, and many clients, by default publish the metrics to JMX, so if you will not publish the metrics from JMX then you need to add some other dependencies for each library.

Now by using this library you will not need to add metrics reporter for each library.

Maven Dependency

Use the following repository

<repository>
    <id>clojars</id>
    <name>Clojars repository</name>
    <url>https://clojars.org/repo</url>
</repository>

Use the following maven dependency

<dependency>
  <groupId>com.geek-vivek.dropwizard</groupId>
  <artifactId>jmx-dropwizard-metrics</artifactId>
  <version>1.0.0</version>
</dependency>

How to Use ?

    //Get metric registry instance in your application.
    MetricRegistry registry = ...

Now check the JMX metrics that you want to publish. One simple way is to use jconsole and connect to your application on local system. Get the domain name, type name(optional), name of metric

Lets for example, you want to get kafka consume metrics.

When you will check in jconsole, then you will get domain name=kafka.consumer, and so on.

    // After listing down, Now it is time to create filter
    import com.geekvivek.dropwizard.jmxmetricsutils.config.MetricConfig;

    MetricConfig metricConfig = MetricConfig.builder().filters(
        Collections.singletonList(
           MetricConfig.Filter.builder()
                .metricsRegex("kafka.consumer.*")   //regex to filter the metrics
                .metricType("gauge")                 //type of meter to apply on each metrics; supported metricTypes are gauge, histogram, meter
                .build()
        )
    ).build();  

Now Create a instance of JmxToDropwizardReporter and pass that to JMXMetricProviderService and start the JMXMetricProviderService

    new JmxMetricProviderService(Collections.singletonList(
        new JmxToDropwizardReporter(registry, metricConfig)
    )).start(10, 60, TimeUnit.SECONDS);

And you are done. :)

jmx-dropwizard-metrics's People

Contributors

vivek43nit avatar

Stargazers

 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.