Close

Quick Intro to Spring Boot Actuator Endpoints and How to enable them?

[Updated: Apr 12, 2018, Created: Apr 12, 2018]

Spring Boot Actuator includes a number of features related to runtime monitoring and managing of the application. We can use those features via HTTP endpoints or with JMX. In this tutorial we will see how to enable the actuator HTTP endpoints.

Actuator dependency

The dependency of spring-boot-starter-actuator should be included to enable the endpoints:

pom.xml

<project .....>
<modelVersion>4.0.0</modelVersion>
<groupId>com.logicbig.example</groupId>
<artifactId>enabling-actuator-end-point-example</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>

Enabling endpoints

To enable endpoints, we need to assigned their IDs to management.endpoints.web.exposure.include in application.properties. By default only 'health,info' is assigned (Boot 2.0.1.RELEASE). To enable all, '*' can be used.

src/main/resources/application.properties

management.endpoints.web.exposure.include=*

The boot main class

In this simple example we are not defining any MVC controllers. The boot main configuration class does not need anything special:

@SpringBootApplication
public class SpringBootMain {

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

Output

The enabled endpoints can be viewed at /actuator (hypermedia Response):

Accessing specific endpoints:

Other configuration properties

management.endpoints.web.exposure.exclude= # Endpoint IDs that should be excluded.

management.endpoints.web.base-path=/actuator # Base path for HTTP endpoints, default is /actuator.

management.endpoints.web.path-mapping= # Mapping between endpoint IDs and the path that should expose them, e.g. management.endpoints.web.path-mapping.health=healthcheck

Example Project

Dependencies and Technologies Used:

  • spring-boot-starter-actuator 2.0.1.RELEASE: Starter for using Spring Boot's Actuator which provides production ready features to help you monitor and manage your application [Description from spring-boot-starter-actuator-2.0.1.RELEASE.pom]
    Corresponding Spring version: 5.0.5.RELEASE
  • spring-boot-starter-web 2.0.1.RELEASE: Starter for building web, including RESTful, applications using Spring MVC. Uses Tomcat as the default embedded container [Description from spring-boot-starter-web-2.0.1.RELEASE.pom]
    Corresponding Spring version: 5.0.5.RELEASE
  • JDK 1.8
  • Maven 3.3.9

Enabling Spring Boot Actuator Endpoints Select All Download
  • enabling-actuator-end-point-example
    • src
      • main
        • java
          • com
            • logicbig
              • example
        • resources

See Also