Prometheus metrics - not found

℡╲_俬逩灬. 提交于 2020-02-03 08:25:07

问题


I have spring boot application and i am using vertx. I want to monitor the services and the jvm and for that i chose Prometheus.

This is my MonitoringConfig class:

@Configuration
public class MonitoringConfig {

    @Bean
    SpringBootMetricsCollector springBootMetricsCollector(Collection<PublicMetrics> publicMetrics) {

        SpringBootMetricsCollector springBootMetricsCollector = new SpringBootMetricsCollector(publicMetrics);
        springBootMetricsCollector.register();

        return springBootMetricsCollector;
    }

    @Bean
    public ServletRegistrationBean servletRegistrationBean() {
        DefaultExports.initialize();
        return new ServletRegistrationBean(new MetricsServlet(), "/prometheus");
    }

}

And this are my dependencies:

<dependency>
            <groupId>com.moelholm</groupId>
            <artifactId>prometheus-spring-boot-starter</artifactId>
            <version>1.0.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.prometheus/simpleclient -->
        <dependency>
            <groupId>io.prometheus</groupId>
            <artifactId>simpleclient</artifactId>
            <version>0.0.25</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.prometheus/simpleclient_hotspot -->
        <dependency>
            <groupId>io.prometheus</groupId>
            <artifactId>simpleclient_hotspot</artifactId>
            <version>0.0.25</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.prometheus/simpleclient_spring_boot -->
        <dependency>
            <groupId>io.prometheus</groupId>
            <artifactId>simpleclient_spring_boot</artifactId>
            <version>0.0.25</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.prometheus/simpleclient_servlet -->
        <dependency>
            <groupId>io.prometheus</groupId>
            <artifactId>simpleclient_servlet</artifactId>
            <version>0.0.25</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.hateoas</groupId>
            <artifactId>spring-hateoas</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>

It shows no error in the app, but when i am trying to access http://localhost:8787/prometheus i am getting Not Found.

Also i have tried only with actuator and it still the same.

http://localhost:8787/actuator, http://localhost:8787/health and etc. Allways getting: Not found.

So my question is what can cause this and how can i fix this problem?


回答1:


I think that some of the dependencies is causing the problem. Try removing one by one and you can notice where is the problem.

Also for monitoring vert.x application here is a good example that can be useful for you.

About the jvm metrics, add this in your start:

DefaultExports.initialize();

new DropwizardExports(SharedMetricRegistries.getOrCreate("vertx")).register();


来源:https://stackoverflow.com/questions/49530091/prometheus-metrics-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!