Using Micrometer on our Spring Boot Application.

Sujoy Dey
2 min readFeb 2, 2022

In this tutorial we will demonstrate how we could use Micrometer to monitor our Spring Boot Application on the execution of our Restful APIs. We will also identify with Micrometer on how long each API took to complete its execution. Micrometer collects metrics inside our Java application which can benefit from a performance viewpoint.

Dependencies needed for Micrometer:

implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: '2.6.3'implementation group: 'io.micrometer', name: 'micrometer-registry-atlas', version: '1.8.2'implementation group: 'io.micrometer', name: 'micrometer-registry-prometheus', version: '1.8.2'

Add this configuration in the application.properties file:

management.endpoints.web.exposure.include=health,info,prometheus

Below you can see the endpoint from Service A which returns a 500-error code and an exception as Service B is unavailable.

On line 216, this displays a status code of 500, the outcome of the response which is an SERVER_ERROR, and duration of the execution of the API.

Now Service B is up:

Below displays the number of times the API has being executed which is 2(line 212) and how long the API took to execute(line 213).

--

--