When I access the /health
endpoint from my Spring Boot application (1.2.4.RELEASE) it is returning a status of DOWN
:
{
status: \"DO
For springboot 2.3.2 and above just adding
I got this fixed using below code.
Wrote a controller which accepts "/private/health" mapping (You can use /health instead).
import io.swagger.annotations.Api;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping
@Api(value = "Heath Service Health", description = "Heath Service Health")
public class HeathController {
@GetMapping(value = "/private/health")
@ResponseStatus(HttpStatus.OK)
HealthStatusDto healthCheck() {
return HealthStatusDto.builder().status("UP").build();
}
}
Below class is optional. Instead of returning HealthStatusDto in above controller you can return any other message as a String.
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@Data
@AllArgsConstructor
@Builder
public final class HealthStatusDto {
private final String status;
}
Add below config in application.yml
# actuator
# Disable Spring security
management:
security:
enabled: false
# Disable actuators
endpoints:
actuator:
enabled: false
enabled: false
Hope this helps
in my case, I needed both these properties to get more details :
endpoints.health.sensitive: false
management.security.enabled: false
Otherwise, all I was getting was an DOWN status.
I had an issue with RabbitMQ connection : my application is not using it yet, but we've started wiring some code related to it. The application works fine, but we were getting DOWN health status, which was quite puzzling : Spring Boot is surprisingly silent in the logs, as no error shows at startup (I'll probably need to change my config to make it more verbose)
You guy are probably using Consul 1.0. There is a known issue in Spring Could Consul 1.1.0 or so with Consul 1.0. See this - https://github.com/spring-cloud/spring-cloud-consul/issues/365 and this - https://github.com/hashicorp/consul/issues/3635
You will have to upgrade to Spring Could Consul 1.3.0.RELEASE.
If you just added endpoint and it is down check maybe something of default checks is down see the link to see what is checked by default. in my case I forgot to run elastic, so health-check reported "down" as Rashmi pointed out you can disable defaults by management.health.defaults.enabled=false
, but it is better to find the actual reason why
I got the same issue when I upgraded an application from spring boot 1.5 to 2.3.5.RELEASE.
Adding endpoints.health.sensitive
and other properties as mentioned in other answers to application.properties
didn't work for me.
I fixed the issue by excluding RabbitAutoConfiguration
.
@EnableAutoConfiguration(exclude = { RabbitAutoConfiguration.class })