This article translated from: www.elastic.co/guide/en/el…

Elasticsearch cluster Health Check for Elasticsearch

Cluster health

We start with a basic health check that we can use to see what our cluster is doing. We’ll use curl to do this, but you can use any tool that allows you to make HTTP/REST calls (like browsers and Postman). Assuming we are still on the same node, we start Elasticsearch and open another command shell window. To check cluster health, we will use the _cat API. You can run the following command in the Kibana console (the presentation layer in ELK, often packaged with ES) by copying the link and pasting it into the terminal.

GET /_cat/health? vCopy the code

The return result is:

epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time Active_shards_percent 1475247709 17:01:49 ElasticSearch Green 1 100 00 00-100.0%Copy the code

We can see that our cluster named “ElasticSearch” is already in green.

Whenever we ask for cluster health, we get green, yellow, or red status identifiers. Green means that everything is fine (the cluster is fully functional), yellow means that all data is available, but some copies have not been allocated (the cluster is fully functional), and red means that some data cannot be used for some reason. Note that even if the cluster is red, it is still partially functional (that is, it will continue to serve search requests from available shards), but you may need to fix it as soon as possible due to your lack of data.

Also from the above response, we can see that there is a total of 1 node, and we have 0 shards because we have no data yet. Note that because we used the default cluster name (ElasticSearch), and because ElasticSearch uses unicast network discovery by default to find other nodes on the same machine, it is possible to accidentally start multiple nodes on the machine and have them join the cluster. In this case, you might see more than 1 node in the response above.

We can also get the following list of nodes in our cluster:

GET /_cat/nodes? vCopy the code

Return is:

Percent CPU load_1m load_5m load_15m node.role Master name 127.0.0.1 10 5 5 4.46mdi * PB2SGZYCopy the code

Here, we can see one of our nodes named “PB2SGZY”, which is a single node currently in our cluster.