You can call a health-related API operation to view the health status of your Alibaba Cloud Elasticsearch cluster. This helps you mitigate potential risks.
Prerequisites
Procedure
- Log on to the Kibana console of your Elasticsearch cluster.
For more information, see Log on to the Kibana console.
- In the left-side navigation pane, click Dev Tools.
- On the Console tab, run the following command to query the health status of your Elasticsearch cluster:
GET /_cluster/health
If the command is successfully executed, the following result is returned:{ "cluster_name" : "es-cn-45xxxxxxxxxxxxk1q", "status" : "green", "timed_out" : false, "number_of_nodes" : 2, "number_of_data_nodes" : 2, "active_primary_shards" : 18, "active_shards" : 36, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 0, "delayed_unassigned_shards" : 0, "number_of_pending_tasks" : 0, "number_of_in_flight_fetch" : 0, "task_max_waiting_in_queue_millis" : 0, "active_shards_percent_as_number" : 100.0 }
Thestatus
parameter indicates the health status of the Elasticsearch cluster. Valid values aregreen
,yellow
, andred
.Value State Description red Not all of the primary shards are available. One or more indexes have unassigned primary shards. yellow All primary shards are available, but not all of the replica shards are available. One or more indexes have unassigned replica shards. green All primary and replica shards are available. All indexes in the cluster are healthy and do not have unassigned shards. If your Elasticsearch cluster is in theyellow
state, operations on the cluster require a longer time to complete. These operations include password changes and cluster configuration upgrades. If your cluster is not in thegreen
state, we recommend that you recover indexes before you perform other operations. If an index in your cluster has unassigned replica shards, your cluster is in theyellow
state. In this case, you must perform the following operations to locate the index and recover it:- Query the status of all indexes
curl -u <Username>:<Password> http://<host>:9200/_cat/indices
The index that is in theyellow
state is the one that has unassigned replica shards. - Recover the index
If the number of replica shards that you specify for the index is greater than the number of nodes minus 1, the cluster is in the
yellow
state. You can run the following command to adjust the number of replica shards. For example, your cluster has three nodes, and one or more indexes have three replica shards for each primary shard. In this case, the cluster is in theyellow
state. To resolve this issue, set the number of replica shards to 2 for these indexes.curl -XPUT -u <Username>:<Password> http://<host>:9200/<Index that has unassigned replica shards>/_settings -H 'Content-Type: application/json' -d '{"index":{"number_of_replicas":(<Number of nodes - 1>)}'
Note After you customize the configuration of, scale out, or restart your Elasticsearch cluster, set the number of replica shards to a suitable value based on the number of nodes. This improves the reliability and stability of your Elasticsearch cluster.
- Query the status of all indexes