How to expose metrics to http in dropwizard?

268 views Asked by At

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 ?

1

There are 1 answers

0
gstackoverflow On BEST ANSWER

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

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