0
0
SpringbootHow-ToBeginner · 4 min read

How to Use Info Endpoint Actuator in Spring Boot

To use the info endpoint in Spring Boot Actuator, add the spring-boot-starter-actuator dependency and enable the info endpoint in your application.properties. Customize the information by adding properties under info.* or by creating a bean that provides additional info.
📐

Syntax

The info endpoint is part of Spring Boot Actuator and is enabled by default in recent versions. You configure it mainly through application.properties or application.yml using info.* properties. You can also add custom info by defining a bean of type InfoContributor.

  • spring-boot-starter-actuator: Adds actuator support.
  • management.endpoints.web.exposure.include=info: Ensures the info endpoint is exposed over HTTP.
  • info.* properties: Define static info like version, description.
  • InfoContributor: Java interface to add dynamic info.
properties
dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
}

# application.properties
management.endpoints.web.exposure.include=info
info.app.name=MyApp
info.app.version=1.0.0
💻

Example

This example shows how to enable the info endpoint and add custom information both via properties and a Java bean.

java
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.actuate.info.InfoContributor;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class InfoEndpointExampleApplication {

    public static void main(String[] args) {
        SpringApplication.run(InfoEndpointExampleApplication.class, args);
    }

    @Bean
    public InfoContributor customInfoContributor() {
        return builder -> builder.withDetail("custom", "This is custom info");
    }
}

# application.properties
management.endpoints.web.exposure.include=info
info.app.name=InfoApp
info.app.version=2.1.0
Output
{ "app": { "name": "InfoApp", "version": "2.1.0" }, "custom": "This is custom info" }
⚠️

Common Pitfalls

  • Not including spring-boot-starter-actuator dependency will disable actuator endpoints.
  • Forgetting to expose the info endpoint via management.endpoints.web.exposure.include means it won't be accessible over HTTP.
  • Adding info properties without the info. prefix will not show up in the endpoint.
  • Custom InfoContributor beans must be registered as Spring beans to be effective.
properties
## Wrong: Missing exposure property
# application.properties
info.app.name=MyApp

## Right: Include exposure
management.endpoints.web.exposure.include=info
info.app.name=MyApp
📊

Quick Reference

ConfigurationDescription
spring-boot-starter-actuatorDependency to add actuator support
management.endpoints.web.exposure.include=infoExpose info endpoint over HTTP
info.* propertiesStatic info data shown in the endpoint
InfoContributor beanAdd dynamic or custom info programmatically

Key Takeaways

Add spring-boot-starter-actuator to enable actuator endpoints including info.
Expose the info endpoint with management.endpoints.web.exposure.include=info.
Use info.* properties to add static metadata like app name and version.
Create InfoContributor beans to add custom dynamic information.
Always verify the endpoint is accessible at /actuator/info after setup.