当前位置: 首页 > 知识库问答 >
问题:

Spring boot未在promethesendpoint注册

杨乐意
2023-03-14

我正在尝试用spring boot配置普罗米修斯(Prometheus)和格拉法纳(Grafana)。

@Configuration
@EnableSpringBootMetricsCollector
public class MetricsConfiguration {

    /**
     * Register common tags application instead of job. This application tag is
     * needed for Grafana dashboard.
     *
     * @return registry with registered tags.
     */

    @Value("${spring.application.name}")
    private String applicationName;

    @Value("${spring.profiles.active}")
    private String environment;


    @Bean
    public MeterRegistryCustomizer<MeterRegistry> metricsCommonTags() {
        return registry -> {
            registry.config().commonTags("application", applicationName, "environment", environment)
                    .meterFilter(getDefualtConfig());
        };
    }

    private MeterFilter getDefualtConfig() {
        return new MeterFilter() {
            @Override
            public DistributionStatisticConfig configure(Meter.Id id, DistributionStatisticConfig config) {
                return DistributionStatisticConfig.builder().percentilesHistogram(true).percentiles(0.95, 0.99).build()
                        .merge(config);
            }
        };
    }

}

在运行应用程序时,我可以看到localhost:8080/prometheusurl的训练。

但我无法在localhost上看到相同的内容:9090/metrics url,这是普罗米修斯的url。

我在普罗米修斯中添加了配置。yml重新启动了普罗米修斯号。

- job_name: 'my-api'
    scrape_interval: 10s
    metrics_path: '/prometheus'
    target_groups:
       - targets: ['localhost:8080']

共有1个答案

卜凯旋
2023-03-14

在花了2个小时找到解决方案后,我们对所有健康点也使用了基本身份验证问题是我没有在我的proemtheus.yml中设置基本身份验证

- job_name: 'my-api'
    scrape_interval: 10s
    metrics_path: '/prometheus'
    target_groups:
       - targets: ['localhost:8080']
    basic_auth:
      username: test
      password: test
 类似资料:
  • 我在尝试执行此代码时遇到以下错误。 java.lang.IllegalArgumentException:在“com.app.aggregatorappaconfiguration”上找不到ConfigurationProperties注释。在org.springframework.util.assert.NotNull(assert.java:115)~[spring-core-4.3.2.re

  • 该应用程序在Eureka注册后以“未知”的状态启动,并且从未更改为“启动”。如果这些标志中的任何一个被设置为false,那么应用程序启动时注册为“up”。 当两个标志都启用/true时,我看到了以下一系列日志记录: 我如何让应用程序注册为启用了这两个标志/真? bootstrap.yml

  • 主要内容:1.@Transactional 失败的情况,2.@Transactional 源码分析,3.@Transactional 失效原因1.@Transactional 失败的情况 UserDao UserController @Transactional 事务不生效的几种情况 类内部访问:A 类的 a1 方法没有标注 @Transactional,a2 方法标注 @Transactional,在 a1 里面调用 a2; 私有方法:将 @Transactional 注解标注在非 publi

  • 我对这个php_oci8.dll图书馆很困惑。 我已经设置了PATH变量。我确信php_oci8.dll已经存在于xampp/php/ext文件夹中。我确信我已经取消评论扩展=php_oci8.dll. 问题是:1.当我访问phpinfo()时,我没有看到加载任何ococ8,但是,当我运行cmd命令时,它说启用

  • 我刚刚关注了下面这篇文章,https://spring.io/blog/2015/07/14/microservices-with-spring,但是我无法在尤里卡注册我的微服务。 customer-service.yml build . gradle for customer-service CustomerService.java 注册-server.yml

  • 本文向大家介绍springboot注入servlet的方法,包括了springboot注入servlet的方法的使用技巧和注意事项,需要的朋友参考一下 问:有了springMVC,为什么还要用servlet?有了servlet3的注解,为什么还要使用ServletRegistrationBean注入的方式? 使用场景:在有些场景下,比如我们要使用hystrix-dashboard,这时候就需要注入