javaspringspring-bootdatasourcespring-boot-actuator

Disabling HealtCheck for specific DataSources in Spring Actuator


i have issue with disabling specific DataSources in Spring Actuator. I currently have task in my application to implement Spring Actuator, but need Actuator to ignore/disable for some features in app(Health Indicator mainly). Application is built from other mini apps. Any suggestions or instructions how to start it ?


Solution

  • Disable the default datasources health indicator

    management.health.db.enabled=false
    

    and customise the your required data source with DataSourceHealthIndicator

    example:

    @Autowired
    private DataSource requiredDataSource;
    
    @Bean
    public DataSourceHealthIndicator requiredDataSourceHealthIndicator() {
        return new DataSourceHealthIndicator(requiredDataSource);
    }