小编典典

Prometheus指标-找不到

spring-boot

我有Spring Boot应用程序,我正在使用vertx。我想监视服务和jvm,为此我选择了Prometheus。

这是我的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");
    }

}

这是我的依赖项:

<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>

它在应用程序中没有显示任何错误,但是当我尝试访问http:// localhost:8787 /
prometheus时,
我却找不到了。

我也只尝试与执行器,它仍然相同。

http:// localhost:8787 / actuatorhttp://
localhost:8787 / health
等。始终获得:找不到。

所以我的问题是什么会引起这个问题,我该如何解决呢?


阅读 449

收藏
2020-05-30

共1个答案

小编典典

我认为某些依赖性导致了问题。尝试一一移除,您会发现问题出在哪里。

对于监测vert.x应用在这里是可以对您有用一个很好的例子。

关于JVM指标,请在开始时添加它:

DefaultExports.initialize();

new DropwizardExports(SharedMetricRegistries.getOrCreate("vertx")).register();
2020-05-30