Elasticsearch cluster status

Terminology

An Elasticsearch cluster is made up of one or more nodes.
Each of these nodes contains indexes which are split into multiple shards.
Elasticsearch makes copies of these shards called replicas.
These (primary) shards and replicas are then placed on various nodes throughout the cluster.

Status

Cluster Health API

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
curl -XGET http://192.168.3.11:9200/_cluster/health

{
"cluster_name" : "testcluster",
"status" : "yellow",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 5,
"active_shards" : 5,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 5,
"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": 50.0
}
  • RED:
    Damnit. Some or all of (primary) shards are not ready.

  • YELLOW:
    Elasticsearch has allocated all of the primary shards, but some/all of the replicas have not been allocated.

  • GREEN:
    Great. Your cluster is fully operational. Elasticsearch is able to allocate all shards and replicas to machines within the cluster.

Request Parameters

  • level
    Can be one of cluster, indices or shards. Controls the details level of the health information returned. Defaults to cluster.
  • wait_for_status
    One of green, yellow or red. Will wait (until the timeout provided) until the status of the cluster changes to the one provided or better, i.e. green > yellow > red. By default, will not wait for any status.
  • wait_for_no_relocating_shards
    A boolean value which controls whether to wait (until the timeout provided) for the cluster to have no shard relocations. Defaults to false, which means it will not wait for relocating shards.
  • wait_for_active_shards
    A number controlling to how many active shards to wait for, all to wait for all shards in the cluster to be active, or 0 to not wait. Defaults to 0.
  • wait_for_nodes
    The request waits until the specified number N of nodes is available. It also accepts >=N, <=N, >N and <N. Alternatively, it is possible to use ge(N), le(N), gt(N) and lt(N) notation.
  • timeout
    A time based parameter controlling how long to wait if one of the wait_for_XXX are provided. Defaults to 30s.
  • local
    If true returns the local node information and does not provide the state from master node. Default: false.
1
curl -XGET http://192.168.3.11:9200/_cluster/health?wait_for_status=yellow&timeout=50s