Cluster health APIedit

Returns the health status of a cluster.


GET _cluster/health/<target>


The cluster health API returns a simple status on the health of the cluster. You can also use the API to get the health status of only specified data streams and indices. For data streams, the API retrieves the health status of the stream’s backing indices.

The cluster health status is: green, yellow or red. On the shard level, a red status indicates that the specific shard is not allocated in the cluster, yellow means that the primary shard is allocated but replicas are not, and green means that all shards are allocated. The index level status is controlled by the worst shard status. The cluster status is controlled by the worst index status.

One of the main benefits of the API is the ability to wait until the cluster reaches a certain high water-mark health level. For example, the following will wait for 50 seconds for the cluster to reach the yellow level (if it reaches the green or yellow status before 50 seconds elapse, it will return at that point):

$response = $client->cluster()->health();
var healthResponse = client.Cluster.Health(selector: h => h
resp ="yellow", timeout="50s")
response =
  wait_for_status: 'yellow',
  timeout: '50s'
puts response
res, err := es.Cluster.Health(
fmt.Println(res, err)
const response = await{
  wait_for_status: 'yellow',
  timeout: '50s'
GET /_cluster/health?wait_for_status=yellow&timeout=50s

Path parametersedit


(Optional, string) Comma-separated list of data streams, indices, and index aliases used to limit the request. Wildcard expressions (*) are supported.

To target all data streams and indices in a cluster, omit this parameter or use _all or *.

Query parametersedit

(Optional, string) Can be one of cluster, indices or shards. Controls the details level of the health information returned. Defaults to cluster.
(Optional, Boolean) If true, the request retrieves information from the local node only. Defaults to false, which means information is retrieved from the master node.
(Optional, time units) Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Defaults to 30s.
(Optional, time units) Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Defaults to 30s.
(Optional, string) 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.
(Optional, string) Can be one of immediate, urgent, high, normal, low, languid. Wait until all currently queued events with the given priority are processed.
(Optional, Boolean) A boolean value which controls whether to wait (until the timeout provided) for the cluster to have no shard initializations. Defaults to false, which means it will not wait for initializing shards.
(Optional, Boolean) 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.
(Optional, string) 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.
(Optional, string) 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.

Response bodyedit

(string) The name of the cluster.

(string) Health status of the cluster, based on the state of its primary and replica shards. Statuses are:

All shards are assigned.
All primary shards are assigned, but one or more replica shards are unassigned. If a node in the cluster fails, some data could be unavailable until that node is repaired.
One or more primary shards are unassigned, so some data is unavailable. This can occur briefly during cluster startup as primary shards are assigned.
(Boolean) If false the response returned within the period of time that is specified by the timeout parameter (30s by default).
(integer) The number of nodes within the cluster.
(integer) The number of nodes that are dedicated data nodes.
(integer) The number of active primary shards.
(integer) The total number of active primary and replica shards.
(integer) The number of shards that are under relocation.
(integer) The number of shards that are under initialization.
(integer) The number of shards that are not allocated.
(integer) The number of shards whose allocation has been delayed by the timeout settings.
(integer) The number of cluster-level changes that have not yet been executed.
(integer) The number of unfinished fetches.
(integer) The time expressed in milliseconds since the earliest initiated task is waiting for being performed.
(float) The ratio of active shards in the cluster expressed as a percentage.


$response = $client->cluster()->health();
var healthResponse = client.Cluster.Health();
resp =
response =
puts response
res, err := es.Cluster.Health()
fmt.Println(res, err)
const response = await
GET _cluster/health

The API returns the following response in case of a quiet single node cluster with a single index with one shard and one replica:

  "cluster_name" : "testcluster",
  "status" : "yellow",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 1,
  "active_shards" : 1,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 1,
  "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

The following is an example of getting the cluster health at the shards level:

GET /_cluster/health/my-index-000001?level=shards