Writing custom endpoints in Spring Actuator

Leo Gutiérrez
4 min readSep 26, 2020

Hello! recently I had to write some custom endpoints using Spring Actuator in a little Spring Boot application, in this short but pragmatic post I will show two ways of writing custom endpoints.

Requirements / Configuration

First of all you need to make sure you have the following dependency in your pom.xml

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

Now we require some slight changes to our application.properties or application.yml, depends on what you are using.

I want to expose all the endpoints, for that I will the following configuration:

management.endpoints.web.exposure.include=*

But you can also expose individual beans:

management.endpoints.web.exposure.include=env,beans,metrics

With the above configuration, you should be able to see something like this if you go to your browser and check localhost:8080/actuator

Or you could also use HTTPie or curl:

--

--

Leo Gutiérrez
Leo Gutiérrez

Written by Leo Gutiérrez

Hi! I am Leonardo Gutiérrez R., a passionate software developer, I hope you find the content in this blog interesting. I write about IT related stuff.

No responses yet