简体   繁体   English

Prometheus指标 - 未找到

[英]Prometheus metrics - not found

I have spring boot application and i am using vertx. 我有春季启动应用程序,我正在使用vertx。 I want to monitor the services and the jvm and for that i chose Prometheus. 我想监控服务和jvm,为此我选择了Prometheus。

This is my MonitoringConfig class: 这是我的MonitoringConfig类:

@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. 它在应用程序中显示没有错误,但是当我尝试访问http:// localhost:8787 / prometheus时,我收到了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. http:// localhost:8787 /执行器http:// localhost:8787 / health等等。总是得到:找不到。

So my question is what can cause this and how can i fix this problem? 所以我的问题是什么可以导致这个,我该如何解决这个问题?

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. 此外,对于监视vert.x应用程序, 是一个对您有用的好例子。

About the jvm metrics, add this in your start: 关于jvm指标,请在开头添加:

DefaultExports.initialize();

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM