Controlling cluster health via an API
In the Understanding cluster, replication and sharding recipe in Chapter 1, Getting Started, we discussed the Elasticsearch clusters and how to manage them in a red and yellow state.
Elasticsearch provides a convenient way to manage the cluster state, which is one of the first things to check if any problems occur.
Getting ready
You need an up-and-running Elasticsearch installation as we described in the Downloading and installing Elasticsearch recipe in Chapter 2, Downloading and Setup.
To execute curl
via command line you need to install curl
for your operating system.
How to do it...
For controlling the cluster health, we will perform the following steps:
To view the cluster health, the HTTP method is
GET
and thecurl
command is as follows:curl -XGET 'http://localhost:9200/_cluster/health?pretty'
The result will be as follows:
{ "cluster_name" : "elasticsearch", "status" : "yellow", "timed_out" : false, ...