Spring Boot Actuator - Cannot Disable Default Management Health Checks
When building a Spring Boot 1.1.9.RELEASE application with Spring Boot Actuator enabled, I cannot seem to disable the built in management.health checks. The health checks in question are:
management.health.db.enabled=false
management.health.diskspace.enabled=false
management.health.mongo.enabled=false
management.health.rabbit.enabled=false
management.health.redis.enabled=false
management.health.solr.enabled=false
After adding these lines to my application.properties file, I get errors on app start such as:
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'managementServerProperties': Could not bind properties; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'health[diskspace][enabled]' of bean class [org.springframework.boot.actuate.autoconfigure.ManagementServerProperties]: Cannot access indexed value in property referenced in indexed property path 'health[diskspace][enabled]'; nested exception is org.springframework.beans.NotReadablePropertyException: Invalid property 'health[diskspace][enabled]' of bean class [org.springframework.boot.actuate.autoconfigure.ManagementServerProperties]: Bean property 'health[diskspace][enabled]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:300)
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:252)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:407)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1546)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:706)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:762)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:109)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:952)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:941)
at com.premierinc.chna.Application.main(Application.java:24)
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'health[diskspace][enabled]' of bean class [org.springframework.boot.actuate.autoconfigure.ManagementServerProperties]: Cannot access indexed value in property referenced in indexed property path 'health[diskspace][enabled]'; nested exception is org.springframework.beans.NotReadablePropertyException: Invalid property 'health[diskspace][enabled]' of bean class [org.springframework.boot.actuate.autoconfigure.ManagementServerProperties]: Bean property 'health[diskspace][enabled]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:947)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:923)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:82)
at org.springframework.validation.DataBinder.applyPropertyValues(DataBinder.java:728)
at org.springframework.validation.DataBinder.doBind(DataBinder.java:624)
at org.springframework.boot.bind.RelaxedDataBinder.doBind(RelaxedDataBinder.java:93)
at org.springframework.validation.DataBinder.bind(DataBinder.java:609)
at org.springframework.boot.bind.PropertiesConfigurationFactory.doBindPropertiesToTarget(PropertiesConfigurationFactory.java:275)
at org.springframework.boot.bind.PropertiesConfigurationFactory.bindPropertiesToTarget(PropertiesConfigurationFactory.java:225)
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:297)
... 18 more
Caused by: org.springframework.beans.NotReadablePropertyException: Invalid property 'health[diskspace][enabled]' of bean class [org.springframework.boot.actuate.autoconfigure.ManagementServerProperties]: Bean property 'health[diskspace][enabled]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:726)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:944)
... 27 more
Basically, I don't want Spring reporting that services are down that I don't even have in my project, but when I try to disable them, the app breaks. I have custom health checks that I want to register, but that's all I want.
Am I missing something obvious?
Thanks!
Similar problem here with version 1.2.0. Trying:
management.health.diskspace.enabled=true
management.health.diskspace.path=/
management.health.diskspace.threshold=10485760
management.health.db.enabled=true
And it is failing with similar exceptions. Whatever the values after the '='
This looks like a bug. It seems that we are trying to bind those values to HealthMvcEndpointProperties.
Possibly a duplicate of #2115 although that seems have only been fixed on master and hasn't changed the HealthMvcEndpointProperties class.
There's two different issues here, really.
The culprit on master is 00961611 and #2115 does indeed fix it (the tests have been updated to represent a more realistic scenario). @tleveque23 you can try the latest snapshot.
On 1.1.x, those keys were on the health.* namespace (see #1841). @MatthewEdge fix your configuration to use the health.* namespace (i.e. health.db.enabled=falseand you'll be fine).
To be fully honest, the documentation on that feature was a bit low and was reviewed in 1.2.x. Maybe I should have backported that to the branch so that's clear what you have to use. Another thing we could do is restore the old keys in deprecated mode so that both would work (I did not anticipate this to be a real problem, maybe I am wrong). Feel free to open an issue if you really need it.
@snicoll Perfect, that solved my issue. For future users who may run into the same issue, I'd recommend updating the keys displayed on http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#common-application-properties
The # HEALTH INDICATORS section lists the management namespace for these keys
Thanks everybody!
I am confused. What do you want us to update exactly? These are the proper keys...
Woops, accidentally linked to the current docs. Previous doc versions don't even have those keys listed anywhere
So I guess my concern is users on earlier versions will turn to the documentation, see those keys, and run into the same issue I ran into where management.health is actually health. Would be nice to have that noted somewhere
Cheers
Oh gotcha. Let me do that.
Reference doc add in 1.1.x with 2416a935e6ca64b76 and an explicit reference has been added to master as well (b8612d99c6b17). Thanks!
In the application, I have enabled the SOLR health check. We are using SOLR cloud multiple nodes env. and using Zuul (3 nodes) . someone inform how to configure it
@jofisiva Please ask questions on Stack Overflow or Gitter. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.