0

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 ?

gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
  • What is unclear about the getting started guide? It contains examples on how to add metrics in code, and multiple options to retrieve metrics report (console, http or jmx). Please describe the problem you’re facing and what you have tried. – slindenau Jun 28 '22 at 16:37
  • @slindenau I have metrics in code and I see them in console after adding ConsoleReporter. It is clear. Now I want to execute GET request and receive metrics. In guide I've found that only dependency is required. But where I can find metrics ? what URL should I use ? – gstackoverflow Jun 28 '22 at 16:41
  • Quote from the bottom of the page: `From there on, you can map the servlet to whatever path you see fit`. Looks like you need to manually map it. – slindenau Jun 28 '22 at 16:44
  • @slindenau Which Servlet ? I AdminServlet ? MetricsServlet ? – gstackoverflow Jun 28 '22 at 16:49
  • @slindenau Thanks, it helped https://stackoverflow.com/a/72790421/2674303 – gstackoverflow Jun 28 '22 at 16:52

1 Answers1

1

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

@Bean
public ServletRegistrationBean servletRegistrationBean(MetricRegistry metricRegistry){
    return new ServletRegistrationBean(new MetricsServlet(metricRegistry),"/metrics/*");
}
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710