普罗米修斯指标 - 未找到 [英] Prometheus metrics - not found

查看:75
本文介绍了普罗米修斯指标 - 未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

这是我的 MonitoringConfig 类:

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

}

这是我的依赖项:

<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 我找不到.

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 等.总是得到:未找到.

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?

推荐答案

我认为是某些依赖项导致了问题.试着一一删除,你就会发现问题出在哪里.

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

也用于监控 vert.x 应用程序这里是一个很好的例子,可以对你有用.

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

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

About the jvm metrics, add this in your start:

DefaultExports.initialize();

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

这篇关于普罗米修斯指标 - 未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆