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

An Elasticsearch cluster is created. For more information, see Create an Elasticsearch cluster.

Procedure

  1. Log on to the Kibana console of your Elasticsearch cluster.
    For more information, see Log on to the Kibana console.
  2. In the left-side navigation pane, click Dev Tools.
  3. 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
    }
    The status parameter indicates the health status of the Elasticsearch cluster. Valid values are green, yellow, and red.
    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 the yellow 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 the green 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 the yellow 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 the yellow state is the one that has unassigned replica shards.Index 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 the yellow 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.