![](/img/trans.png)
[英]Spring Boot 2 Actuator /health and /info returns HTTP 404
[英]Spring Actuator /info returns an empty body
如何在 Spring Actuator 2.7.0 中向 /info 端点添加自定义指标?
目前有以下与执行器相关的内容。 我已经验证 info.app.version 可以使用 @Value 从 pom.xml 中检索正确的值。
pom.xml
<version>0.0.1-SNAPSHOT</version>
...
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.7.0</version>
</dependency>
应用程序属性
info.app.version=@project.version@
management.endpoint.info.enabled=true
management.endpoints.web.exposure.include=info,health
但尽管如此,我在 /info 上只得到一个空的回复。 响应 header:
< HTTP/1.1 200
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< X-Frame-Options: DENY
< Content-Type: application/vnd.spring-boot.actuator.v3+json
< Transfer-Encoding: chunked
< Date: Wed, 15 Jun 2022 04:12:47 GMT
* Received 7 B chunk
* Received 5 B chunk
* Connection #26 to host localhost left intact
回复正文:
{}
我的理解是info
下的任何属性都包含在/info
端点中。 或者这不适用于执行器 v2+? 资源
来自 Spring-Boot 2.6 发行说明https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.6-Release-Notes#actuator-env-infocontributor-disabled-by-default
您需要启用 info env 属性:
management.info.env.enabled=true
最新的 spring 启动需要设置两件事:
1-在application.properties
文件中公开端点:
management.endpoints.web.exposure.include=info, health
如果需要,您可以使用通配符并公开所有端点
management.endpoints.web.exposure.include=*
2- 在application.properties
中启用 info.env :
management.info.env.enabled=true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.