[英]Spring Actuator /info returns an empty body
How to add custom metrics to /info endpoint in Spring Actuator 2.7.0?如何在 Spring Actuator 2.7.0 中向 /info 端点添加自定义指标?
Currently have the following related to actuator.目前有以下与执行器相关的内容。 I have verified that info.app.version can retrieve the proper value from pom.xml using @Value.
我已经验证 info.app.version 可以使用 @Value 从 pom.xml 中检索正确的值。
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>
application.properties应用程序属性
info.app.version=@project.version@
management.endpoint.info.enabled=true
management.endpoints.web.exposure.include=info,health
But despite this I am only getting an empty response on /info.但尽管如此,我在 /info 上只得到一个空的回复。 Response header:
响应 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
Response body:回复正文:
{}
My understanding is any property under info
is included in /info
endpoint.我的理解是
info
下的任何属性都包含在/info
端点中。 Or does this not work on actuator v2+?或者这不适用于执行器 v2+? Source
资源
From the Spring-Boot 2.6 release notes https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.6-Release-Notes#actuator-env-infocontributor-disabled-by-default来自 Spring-Boot 2.6 发行说明https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.6-Release-Notes#actuator-env-infocontributor-disabled-by-default
You need to enable the info env property:您需要启用 info env 属性:
management.info.env.enabled=true
Latest spring boot requires two things to be set up:最新的 spring 启动需要设置两件事:
1- exposing the endpoint in application.properties
file: 1-在
application.properties
文件中公开端点:
management.endpoints.web.exposure.include=info, health
You can use a wildcard and expose all endpoints if you want如果需要,您可以使用通配符并公开所有端点
management.endpoints.web.exposure.include=*
2- enabling info.env in application.properties
: 2- 在
application.properties
中启用 info.env :
management.info.env.enabled=true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.