When I access the /health
endpoint from my Spring Boot application (1.2.4.RELEASE) it is returning a status of DOWN
:
{
status: "DOWN"
}
Are there any starter projects or libraries that are known to overwrite the status? Is there any other reason (besides writing a custom one) why it would return DOWN
?
Spring Boot Actuator module helps you monitor and manage your Spring Boot application by providing production-ready features like health check-up, auditing, metrics gathering, HTTP tracing etc. All of these features can be accessed over JMX or HTTP endpoints.
The Actuator module provides useful insight into the Spring environment for a running application with functions for health checking and metrics gathering by exposing multiple endpoints over HTTP and JMX.
Spring Boot Actuator is not working because the spring boot actuator dependency is incorrect or the actuator isn't configured properly in the application. properties file. If the spring boot starter actuator is not configured, endpoints like health, info, shutdown, refresh, env, and metrics may not work.
If you want to completely disable all health indicators available out of the box and instead provide your own health indicators, you can do so by setting property management. health. binders. enabled to false and then provide your own HealthIndicator beans in your application.
In your Spring properties, set endpoints.health.sensitive = false
. The /health
endpoint will then return the list of various health indicators and you can debug from there.
For a production environment you should enable security around the /health
endpoint.
Edit
As Vincent pointed out below, you'll also need management.security.enabled = false
if the health endpoint is secured, which seems to be the default in more recent versions of Spring Boot.
A common issue that I've seen with Spring Boot out of the box is that it auto-configures Solr, and without additional configuration the /health
endpoint indicates that Solr is DOWN
. An easy way to fix this is to disable the Solr auto configuration in your Application.java with this annotation:
@SpringBootApplication(exclude={SolrAutoConfiguration.class})
If the health url shows "DOWN" or HTTP 503 - Service Unavailable error, then try adding the below property in application.properties
URL - http://localhost:8080/actuator/health
management.endpoint.health.show-details=always
Now the url should show more than just DOWN. If Solr host is not reachable, then ignore the Solr check using the below exclusion -
@SpringBootApplication(exclude = { SolrAutoConfiguration.class })
Now the health should come up. The health check basically validates predefined health check internally (Example - DataSourceHealthIndicator, DiskSpaceHealthIndicator, CassandraHealthIndicator
, etc).
If one of the health indicator is down, the health will be down and you can see the error as a response after adding the property mentioned above to application.properties.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With