Spring Actuator /info returns an empty body

Viewed 657

How to add custom metrics to /info endpoint in Spring Actuator 2.7.0?

Currently have the following related to actuator. I have verified that info.app.version can retrieve the proper value from pom.xml using @Value.

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. Response 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. Or does this not work on actuator v2+ ? Source

2 Answers

Latest spring boot requires two things to be set up:

1- exposing the endpoint in application.properties file:

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:

management.info.env.enabled=true
Related