javaspring-bootspring-boot-actuator

Spring Actuator /info returns an empty body


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

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>

Currently have the following related to actuator.

application.properties

info.app.version=@project.version@

management.endpoint.info.enabled=true
management.endpoints.web.exposure.include=info,health

I have verified that the info.app.version property can be retrieved using @Value. 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


Solution

  • From Spring Boot 2.6 Release Notes - Actuator Env InfoContributor Disabled by Default

    You need to enable the info env property:

    management.info.env.enabled=true