Custom Endpoint in Spring Boot Actuator


In the last article, we discussed Spring Boot Actuator.In this post, we will discuss how to create a custom endpoint in Spring Boot Actuator.



The actuator provides production-ready features for Spring Boot application.It will help us to check and manage our application in the production environment.There are a number of endpoints provided by Spring Boot however we may want to create a custom endpoint using Spring Boot Actuator.

Spring Boot 2.x introduced a number of changed including endpoint configurations.In this post, we will create a custom endpoint with Spring Boot 1.x and 2.x.


1. Custom Endpoint using Spring Boot 1.x

To implement a new endpoint for our application using Spring Boot 1.x, we should expose the instance of the custom endpoint class as a bean.We need to implement Endpoint<T> interface.

public class CustomEndpoint implements Endpoint {
    public String getId() {
        return "custom-endpoint";

    public boolean isEnabled() {
        return true;

    public boolean isSensitive() {
        return false;

    public String invoke() {
        return "This is a custom end point for demo purpose";

To access our custom endpoint, use the id field (for our example, it is “custom-endpoint“).

This is a custom end point for demo purpose


2. Custom Endpoint with Spring Boot 2.x

Spring Boot 2 provides an easy way to create custom endpoints.Spring Boot 2.x introduced @Endpoint annotation.Spring Boot automatically expose endpoints with@Endpoint@WebEndpoint, or @WebEndpointExtension over HTTP using Jersey, Spring MVC, or Spring WebFlux.

Spring Boot 2.x Actuator support CURD model, it supports read, writes and delete operation with the endpoints.The @Endpoint annotation can be used in combination with @ReadOperation,@WriteOperation and @DeleteOperation to develop endpoints.


2.1 Creating Custom Endpoint

We are creating a custom health endpoint, this endpoint will provide a custom information to the client.

Data Model 

public class CustomHealth {

    private Map<String, Object> healthDetails;

    public Map<String, Object> getHealthDetails() {
        return this.healthDetails;

Custom Health endpoint.

public class CustomHealthEndPoint {

    public CustomHealth health() {
        Map<String, Object> details = new LinkedHashMap<>();
        details.put("CustomHealthStatus", "Everything looks good");
        CustomHealth health = new CustomHealth();
        return health;

    public String customEndPointByName(@Selector String name) {
        return "custom-end-point";

    public void writeOperation(@Selector String name) {
        //perform write operation
    public void deleteOperation(@Selector String name){
        //delete operation

[pullquote align=”normal”]Keep an eye on #11107 while naming your endpoint. There is an interesting issue if we name our endpoint in camel case [/pullquote]

  • The Id property of the @Endpoint annotation determines the mapping of our endpoint (in our example it is /custom-endpoint).
  • @ReadOperation – HTTP Get method.
  • @WriteOperation – POST method.
  • @DeleteOperation – HTTP DELETE operation.

To access our custom endpoint, use http://host:port/actuator/custom-health to check the output.

"CustomHealthStatus":"Everything looks good"


2.2 Controller Endpoints

Spring Boot Actuator provides an alternate way to create custom endpoints that are only exposed by Spring MVC or Spring WebFlux.Use @ControllerEndpoint and @RestControllerEndpoint for this.While using this approach, we should use standard Spring MVC annotations like @RequestMapping and @GetMapping, with the endpoint’s ID being used as a prefix for the path.

@RestControllerEndpoint(id = "rest-end-point")
public class RestCustomEndPoint {

    public @ResponseBody ResponseEntity customEndPoint(){
        return  new ResponseEntity<>("REST end point", HttpStatus.OK);

Use http://host:port/actuator/rest-end-point/custom to access this custom endpoint.



Spring Boot Actuator provides a number of ready to use powerful features.In this post, we learned to create a custom endpoint in Spring Boot Actuator.We covered creating custom endpoints using both Spring Boot 1.x and 2.x.

Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Newest Most Voted
Inline Feedbacks
View all comments