我已将 Spring Boot 应用程序升级到最新的 2.2.2 Boot 版本。从那以后,我只有一个指标端点,但没有 Prometheus。
我的build.gradle.kts文件具有org.springframework.boot:spring-boot-starter-actuator
依赖项,我还添加io.micrometer:micrometer-registry-prometheus
了参考建议(Prometheus 端点)。
我的application.yml如下所示:
management:
server:
port: 9000
endpoints:
web:
exposure:
include: health, shutdown, prometheus
endpoint:
shutdown:
enabled: true
有人可以指导我走向正确的方向吗?
编辑:它在 Spring Boot 2.2.0 中工作。这是下载相同项目的链接:链接
编辑 2:我可以验证它也适用于 2.2.1。
我按照你的设置,我从这个加载了 Spring Boot 2.2.2.RELEASE的项目创建了一个项目,我添加了以下依赖项Prometheus
implementation("io.micrometer:micrometer-registry-prometheus")
我还添加了以下配置 application.yml
management:
server:
port: 9000
endpoints:
web:
exposure:
include: health, shutdown, prometheus
endpoint:
shutdown:
enabled: true
当应用程序启动时,您将看到以下信息,其中显示 3 个端点已暴露(健康、关机和普罗米修斯)。
2020-01-05 23:48:19.489 INFO 7700 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 3 endpoint(s) beneath base path '/actuator'
并用于此端点的Postman
方法,它运行良好。我按照这里的这些步骤创建了一个存储库所以请让我知道显示了什么错误,或者当你没有得到预期的结果时会发生什么,以便我可以帮助和编辑这个答案。GET
http://localhost:9000/actuator/prometheus
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句