javametricsdropwizardcodahale-metrics

How to expose metrics to http in dropwizard?


I am reading following document:
https://metrics.dropwizard.io/4.2.0/getting-started.html

I've added

<dependency>
    <groupId>io.dropwizard.metrics</groupId>
    <artifactId>metrics-servlets</artifactId>
    <version>${metrics.version}</version>
</dependency>

But what to do next ? How to access metrics ?


Solution

  • I was not able to register AdminServlet but this helped me:

    @Bean
    public ServletRegistrationBean servletRegistrationBean(MetricRegistry metricRegistry){
        return new ServletRegistrationBean(new MetricsServlet(metricRegistry),"/metrics/*");
    }