简体   繁体   English

Spring 引导执行器仅暴露有限的端点

[英]Spring Boot Actuators only exposing limited endpoints

I am trying to expose additional actuator endpoints in my Spring Boot 2.3 service.我试图在我的 Spring Boot 2.3 服务中公开其他执行器端点。 Attempting to add endpoints such as the prometheus and metrics for monitoring.尝试添加端点,例如 prometheus 和监控指标。 But for some reason, the exposed endpoints are locked to the default loggers,health,info.但由于某种原因,暴露的端点被锁定到默认的记录器、健康、信息。

For some background, within the org, there is a parent Spring dependency which automatically brings all of the Spring essentials, as well as some generic code useful within the org.对于某些背景,在组织内,有一个父 Spring 依赖项,它自动带来所有 Spring 必需品,以及一些在组织内有用的通用代码。 I use this dependency in many of my other projects and was able to expose these additional actuator endpoints successfully.我在我的许多其他项目中使用了这种依赖关系,并且能够成功地公开这些额外的执行器端点。 However, in this project with multiple artifacts, I am unable to edit the default exposed actuator endpoints.但是,在这个具有多个工件的项目中,我无法编辑默认公开的执行器端点。

Printing the configurableEnvironment post init always shows the exposure property as follows打印configurableEnvironment post init总是显示暴露属性如下

management.endpoints.web.exposure.include = loggers,health,info

This is after trying to override this property to an expanded list (loggers,health,info,Prometheus,metrics) using below methods:这是在尝试使用以下方法将此属性覆盖到扩展列表(记录器、健康、信息、普罗米修斯、指标)之后:

  • Enabling specific endpoint via management.endpoint.metrics.enabled: true通过management.endpoint.metrics.enabled: true启用特定端点
  • Specifying these values in application.yaml在 application.yaml 中指定这些值
  • Passing this as a Command line arguement Dmanagement.endpoints.web.exposure.include=loggers,health,info,prometheus,metrics将此作为命令行参数传递Dmanagement.endpoints.web.exposure.include=loggers,health,info,prometheus,metrics
  • Using mvn dependency:tree To exclude any transitive actuator dependencies使用mvn dependency:tree排除任何传递性执行器依赖项

I don't believe its due to the org's parent pom, likely due to another dependency we are using.我不相信这是由于组织的父 pom,可能是由于我们正在使用的另一个依赖项。 But due to the size of this project, it is quite hard to remove dependencies to test.但是由于这个项目的规模,很难删除依赖项进行测试。 Is there any way to track down where these properties are set.有没有办法追踪这些属性的设置位置。 Or perhaps additional ways to force exposure of the additional endpoints I want?或者可能是强制暴露我想要的其他端点的其他方法?

—— ——

Actuator config执行器配置

management:
  endpoints:
    web:
      exposure:
        include: metrics,prometheus,info,health,logging
  endpoint:
    env:
      enabled: true
    metrics:
      enabled: true
    info:
      enabled: true
    health:
      enabled: true
      show-details: always
    beans:
      enabled: true
    caches:
      enabled: true
    threaddump:
      enabled: true
    prometheus:
      enabled: true

Actuator info执行器信息

{"_links":{"self":{"href":"http://localhost:9050/actuator","templated":false},"health":{"href":"http://localhost:9050/actuator/health","templated":false},"health-path":{"href":"http://localhost:9050/actuator/health/{*path}","templated":true},"info":{"href":"http://localhost:9050/actuator/info","templated":false},"loggers":{"href":"http://localhost:9050/actuator/loggers","templated":false},"loggers-name":{"href":"http://localhost:9050/actuator/loggers/{name}","templated":true}}}

Your question lacks some background, like your pom.xml or build.gradle files and full application.yml config.您的问题缺乏一些背景,例如您的 pom.xml 或 build.gradle 文件和完整的 application.yml 配置。

I will go through the basic steps, which you may have missed.我将通过基本步骤 go,你可能错过了。

Firstly, please make sure that you've included the Prometheus dependency:首先,请确保您已包含 Prometheus 依赖项:

<dependency>
  <groupId>io.micrometer</groupId>
  <artifactId>micrometer-registry-prometheus</artifactId>
  <scope>runtime</scope>
</dependency>

Also, don't forget that some metrics require the AOP dependency (like custome timers, for example):此外,不要忘记某些指标需要 AOP 依赖项(例如,客户计时器):

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-aop</artifactId>
</dependency>

To enable the Prometheus metrics exposure, you should specify such configuration in your application.yml file (it seems like you did it correctly, but let's list it here for the full picture):要启用 Prometheus 指标公开,您应该在 application.yml 文件中指定此类配置(看起来您做得正确,但让我们在此处列出完整的图片):

management:
  endpoints:
    web.exposure.include: health, info, prometheus

To verify that the Prometheus endpoints were exposed, please use the GET request to this URL: http://localhost:8080/actuator/prometheus要验证 Prometheus 端点是否已暴露,请使用 GET 请求对此 URL: http://localhost:8080/actuator/prometheus

If those steps don't help you resolve your issue, please add more details to your question.如果这些步骤不能帮助您解决问题,请在您的问题中添加更多详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM