【问题标题】:Spring Boot 2 Actuator Micrometer setupSpring Boot 2 执行器千分尺设置
【发布时间】:2020-02-17 19:33:48
【问题描述】:

我有一个 Spring Boot 应用程序并且我有这个依赖项:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-actuator</artifactId>
  <version>2.1.7.RELEASE</version> // From Parent
</dependency>

我还配置了我的application.yml 文件以公开指标:

management:
  endpoints:
    web:
      exposure:
        include: info, health, metrics

我还为 Kafka 创建了一个 Metrics bean:

@Bean
public KafkaConsumerMetrics kafkaConsumerMetrics() {
  return new KafkaConsumerMetrics();
}

但是当我到达端点GET http://localhost:8080/actuator/metrics 时,我得到一个404 Page Not Found 错误。

其他端点(信息/健康)有效:http://localhost:8080/actuator/infohttp://localhost:8080/actuator/health

获取千分尺数据我缺少什么?

【问题讨论】:

  • 你有restricted端点的spring security吗?
  • 我想我不会。如何检查或禁用它?
  • 发表了我的答案。让我知道它是否有帮助

标签: spring spring-boot micrometer spring-micrometer


【解决方案1】:

您可以尝试从配置中启用指标,但默认情况下应该启用它

management:
  endpoint:
    metrics:
      enabled: true

关于执行器属性的更多详细信息https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html#actuator-properties

【讨论】:

  • 将此添加到我的 yaml 中有效。对我来说,问题是 intellij 的工具提示告诉我它默认为 true。您链接的文档也是如此。
猜你喜欢
  • 2021-02-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-15
  • 2020-01-07
  • 1970-01-01
  • 1970-01-01
  • 2022-12-22
相关资源
最近更新 更多