3

I have to check whether my service / app works or not.

I've added dependency

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

and also tried to add management.endpoint.health.show-details: always to application.yml but it didn't help.

I tried to go to http://localhost:8080/actuator/health, http://localhost:8080/health but it returned 404 error.

Jonas
  • 121,568
  • 97
  • 310
  • 388
Programmer
  • 105
  • 2
  • 6

3 Answers3

2

You can try this code on your application.yaml. This is worked for Spring boot 2.6.7.

management:
  endpoint:
    health:
      show-details: always
  endpoints:
    web:
      exposure:
        include: health
séan35
  • 966
  • 2
  • 13
  • 37
0

By default Spring boot enables security for all actuator endpoints

You can disable that feature using below property

management.security.enabled=false  

Henceforth, try to run the application and hit the endpoint

http://localhost:8080/actuator
Nimantha
  • 6,405
  • 6
  • 28
  • 69
Harsh
  • 812
  • 1
  • 10
  • 23
0

As you see, you have 404 both on

http://localhost:8080/actuator/health

and

http://localhost:8080/health

Reason for this is not because security is enabled, if security was enabled you will get 401 or 403. You probably need to expose actuator endpoints in application.yaml file.

Something like this:

management:
 endpoints:
   web:
     exposure:
       include: "health,info"

And if you have security enabled, you need to write you own SecurityFilterChain implementation in which you will disable security on all Actuator endpoints, or in your case only on those that you exposed in your application.yaml file.

Example:

   @Configuration
   class ActuatorSecurityAutoConfiguration {

   @Bean
   SecurityFilterChain 
   surpassingActuatorSecurityFilterChain(HttpSecurity 
   httpSecurity) throws Exception {
     return httpSecurity
            .requestMatcher(EndpointRequest.toAnyEndpoint())
            .authorizeRequests()
            .anyRequest()
            .permitAll()
            .and().build();
     }
   }
trisek
  • 701
  • 6
  • 14