0

Currently elasticsearch is autoconfigured by mentioning this property in application.yml file

spring:
elasticsearch:
    rest:
        uris:

But my requirement is to not keep this property in this file while still have health check enabled. How to manually configure that?

2 Answers2

0

You can simply manually call the REST endpoint of Elasticsearch cluster health API, as you are only calling this REST endpoint, you will have all the control, like duration in which you want to call, what all to parse and how to notify/Act on the status.

Amit
  • 30,756
  • 6
  • 57
  • 88
0

I was manually creating RestHighLevelClient in configuration class so in same class I just added below method to create low level Rest Client which is internally used for autoconfiguring health check and this solved my issue.

//    This low level rest client is used for health check 
@Bean
public RestClient Healthclient() {
    return getClient().getLowLevelClient();
}
public RestHighLevelClient getClient() {
    return client;
}

For more info checkout this - https://github.com/spring-projects/spring-boot/issues/17464