Configure Spring Boot with two ports

As is has been mentioned before, server.port and management.port along with management.context-path properties could be set to make the embedded container to listen on different ports (management-related properties to access Actuator endpoints). To listen on ports other than server.port and management.port: @Configuration public class EmbeddedTomcatConfiguration { @Value(“${server.additionalPorts}”) private String additionalPorts; @Bean public EmbeddedServletContainerFactory servletContainer() { … Read more

/actuator/prometheus missing in @SpringbootTest

Update: @Thierry mentioned @AutoConfigureMetrics is deprecated and one needs to use the @AutoConfigureObservability annotation instead. See his post! Original post: I faced the same issue. After some tracing through spring-context ConditionEvaluator, I found that the newly introduced @ConditionalOnEnabledMetricsExport(“prometheus”) condition on PrometheusMetricsExportAutoConfiguration prevented the endpoint from loading. This is intended behavior due to https://github.com/spring-projects/spring-boot/pull/21658 and impacts … Read more

How to add a custom health check in spring boot health?

Adding a custom health check is easy. Just create a new Java class, extend it from the AbstractHealthIndicator and implement the doHealthCheck method. The method gets a builder passed with some useful methods. Call builder.up() if your health is OK or builder.down() if it is not. What you do to check the health is completely … Read more

How to measure service methods using spring boot 2 and micrometer

@io.micrometer.core.annotation.Timed annotation seems to be out of order for custom calls due to reduction of scope, at it is mentioned in link in your question. You need to manually setup an Aspect: @Configuration @EnableAspectJAutoProxy public class AutoTimingConfiguration { @Bean public TimedAspect timedAspect(MeterRegistry registry) { return new TimedAspect(registry); } } This way method like this: @Timed(“GET_CARS”) … Read more

Unable to access Spring Boot Actuator “/actuator” endpoint

As of spring boot version 2.0.1 using below property would work management.endpoints.web.exposure.include=<comma separated endpoints you wish to expose> You can use * wildcard to expose all actuator endpoints over the web if security isn’t your concern. Also endpoints seems to have moved from previous versions. For ex. if you wish to use beans, you would … Read more

Spring Boot 2 – Actuator Metrics Endpoint not working

I would like to enhance the OP’s answer with more information as I struggled a bit before finally stumbling upon this solution and there seem to be lots of confusion about changes to actuator behavior with Spring Boot 2 What hasn’t changed You need to include a dependency to spring-boot-starter-actuator <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> … Read more

“httptrace” endpoint of Spring Boot Actuator doesn’t exist anymore with Spring Boot 2.2.0

The functionality has been removed by default in Spring Boot 2.2.0. As a workaround, add this configuration to the Spring environment: management.endpoints.web.exposure.include: httptrace and provide an HttpTraceRepository bean like this: @Configuration // @Profile(“actuator-endpoints”) // if you want: register bean only if profile is set public class HttpTraceActuatorConfiguration { @Bean public HttpTraceRepository httpTraceRepository() { return new … Read more

How to enable all endpoints in actuator (Spring Boot 2.0.0 RC1)

With Spring Boot 2.0.0.RC1, actuator endpoints must be 1) enabled and 2) exposed. By default, all endpoints but shutdown are enabled and only health and info are exposed. In your case, the following should work: management.endpoints.web.expose=* # if you’d like to expose shutdown: # management.endpoint.shutdown.enabled=true Note that this changes (again!) as of Spring Boot 2.0.0.RC2: … Read more