Reputation: 86
I've created a custom HealthIndicator which I wants to disable in production until we go live fully. I'm aware there is a property to disable default health indicators (management.health.defaults.enabled=false), but not for custom HealthIndicators.
Is there any way I can temporarily turn off MyCustomHealthIndicator in application property configuration level?
Upvotes: 2
Views: 6294
Reputation: 1
@ConditionalOnEnabledHealthIndicator("your-health")
You can now disable your own health indicator by using the Spring Boot suggested property:
management.health.your-health.enabled=false
This works when we re-start the app. should it work without re-start?
Upvotes: 0
Reputation: 9100
You can use Spring Boot's mechanism without using custom properties. Start by adding an annotation on your class:
@ConditionalOnEnabledHealthIndicator("your-health")
You can now disable your own health indicator by using the Spring Boot suggested property:
management.health.your-health.enabled=false
It has the same effect, but it allows you to group your enabled and disabled health indicators together.
Upvotes: 7
Reputation: 333
Your health indicator bean,
@ConditionalOnProperty(value='health.indicator.enabled')
@Bean
class MyHealthIndicator {
}
In your application.properties file,
health.indicator.enabled=true/false
Hope this helps !
Upvotes: 4