Creating a custom endpoint

We have seen that the Actuator provides several endpoints for your application. But Spring Boot's Actuator also allows you to create a custom endpoint by implementing the EndPoint interface. Let's see the following example:

package com.dineshonjava.sba; import java.util.ArrayList; import java.util.List; import org.springframework.boot.actuate.endpoint.Endpoint; import org.springframework.stereotype.Component; @Component public class MyCustomEndpoint implements Endpoint<List<String>>{ @Override public String getId() { return "myCustomEndpoint"; } @Override public List<String> invoke() { // Custom logic to build the output List<String> list = new ArrayList<>(); list.add("App message 1"); list.add("App message 2"); ...

Get Mastering Spring Boot 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.