- 
                Notifications
    You must be signed in to change notification settings 
- Fork 41.6k
Closed
Labels
status: supersededAn issue that has been superseded by anotherAn issue that has been superseded by another
Description
Hi,
Spring Boot 2.1 add auto-configurations for ElasticSearch RestClient and RestHighLevelClient.
It works well, but there is no actuator health check for the ES Rest clients.
There are two existing HealthIndicator for ES:
- ElasticsearchHealthIndicator: it works only with the tcp client, not the rest one
- ElasticsearchJestHealthIndicator: it works only with the Jest client
A solution would be to add an ElasticsearchRestHealthIndicator or to make the existing ElasticsearchHealthIndicator work with both tcp and rest clients.
For now, I use my own implementation:
@Component
public class ElasticsearchHealthIndicator extends AbstractHealthIndicator {
	@Autowired
	private RestHighLevelClient client;
	@Override
	protected void doHealthCheck(Health.Builder builder) throws IOException {
		ClusterHealthResponse response = client.cluster().health(new ClusterHealthRequest(), RequestOptions.DEFAULT);
		switch (response.getStatus()) {
			case GREEN:
			case YELLOW:
				builder.up();
				break;
			case RED:
			default:
				builder.down();
				break;
		}
	}
}Metadata
Metadata
Assignees
Labels
status: supersededAn issue that has been superseded by anotherAn issue that has been superseded by another