普罗米修斯指标 - 未找到

Bam*_*bus 6 java vert.x spring-boot prometheus

我有 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");
    }

}
Run Code Online (Sandbox Code Playgroud)

这是我的依赖项:

<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>
Run Code Online (Sandbox Code Playgroud)

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

我也只尝试过执行器,但它仍然是一样的。

http://localhost:8787/actuatorhttp://localhost:8787/health等。总是得到:未找到。

所以我的问题是什么会导致这个问题以及如何解决这个问题?

xml*_*ser 2

我认为某些依赖项导致了问题。尝试一一删除,你就能发现问题出在哪里了。

另外,对于监视 vert.x 应用程序,这里有一个很好的示例,对您很有用。

关于 jvm 指标,请在开始时添加以下内容:

DefaultExports.initialize();

new DropwizardExports(SharedMetricRegistries.getOrCreate("vertx")).register();
Run Code Online (Sandbox Code Playgroud)