Controlling cluster health via the API
In the Understanding clusters, replication, and sharding recipe in Chapter 1, Getting Started, we discussed the ElasticSearch cluster and how to manage red and yellow states.
ElasticSearch provides a convenient way to manage cluster state, which is one of the first things to check in case of problems.
Getting ready
You need a working ElasticSearch cluster.
How to do it...
To control cluster health, we will perform the following steps:
- To view cluster health, the HTTP method is GET and the curl command is:
curl -XGET 'http://localhost:9200/_cluster/health?pretty'
- The result will be:
{ "cluster_name" : "elasticsearch", "status" : "green", "timed_out" : false, "number_of_nodes" : 2, "number_of_data_nodes" : 2, "active_primary_shards" : 5, "active_shards" : 10, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards...