2013-08-28 19:24:34 -04:00
|
|
|
[[cluster-health]]
|
|
|
|
== Cluster Health
|
|
|
|
|
|
|
|
The cluster health API allows to get a very simple status on the health
|
2016-07-16 07:13:29 -04:00
|
|
|
of the cluster. For example, on a quiet single node cluster with a single index
|
2018-05-14 12:22:35 -04:00
|
|
|
with one shard and one replica, this:
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2016-07-15 16:28:45 -04:00
|
|
|
GET _cluster/health
|
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
|
|
|
// TEST[s/^/PUT test1\n/]
|
|
|
|
|
|
|
|
Returns this:
|
2016-08-29 17:33:25 -04:00
|
|
|
|
|
|
|
[source,js]
|
2016-07-15 16:28:45 -04:00
|
|
|
--------------------------------------------------
|
2015-06-30 07:53:04 -04:00
|
|
|
{
|
|
|
|
"cluster_name" : "testcluster",
|
2016-07-15 16:28:45 -04:00
|
|
|
"status" : "yellow",
|
2015-06-30 07:53:04 -04:00
|
|
|
"timed_out" : false,
|
2016-07-15 16:28:45 -04:00
|
|
|
"number_of_nodes" : 1,
|
|
|
|
"number_of_data_nodes" : 1,
|
2018-05-14 12:22:35 -04:00
|
|
|
"active_primary_shards" : 1,
|
|
|
|
"active_shards" : 1,
|
2015-06-30 07:53:04 -04:00
|
|
|
"relocating_shards" : 0,
|
|
|
|
"initializing_shards" : 0,
|
2018-05-14 12:22:35 -04:00
|
|
|
"unassigned_shards" : 1,
|
2015-06-30 07:53:04 -04:00
|
|
|
"delayed_unassigned_shards": 0,
|
|
|
|
"number_of_pending_tasks" : 0,
|
|
|
|
"number_of_in_flight_fetch": 0,
|
|
|
|
"task_max_waiting_in_queue_millis": 0,
|
2016-07-15 16:28:45 -04:00
|
|
|
"active_shards_percent_as_number": 50.0
|
2013-08-28 19:24:34 -04:00
|
|
|
}
|
|
|
|
--------------------------------------------------
|
2017-02-22 19:17:34 -05:00
|
|
|
// TESTRESPONSE[s/testcluster/docs_integTestCluster/]
|
2016-07-16 07:13:29 -04:00
|
|
|
// TESTRESPONSE[s/"number_of_pending_tasks" : 0,/"number_of_pending_tasks" : $body.number_of_pending_tasks,/]
|
|
|
|
// TESTRESPONSE[s/"task_max_waiting_in_queue_millis": 0/"task_max_waiting_in_queue_millis": $body.task_max_waiting_in_queue_millis/]
|
|
|
|
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
The API can also be executed against one or more indices to get just the
|
|
|
|
specified indices health:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2016-07-15 16:28:45 -04:00
|
|
|
GET /_cluster/health/test1,test2
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
2016-07-15 16:28:45 -04:00
|
|
|
// CONSOLE
|
|
|
|
// TEST[s/^/PUT test1\nPUT test2\n/]
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
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
|
2013-10-21 07:37:50 -04:00
|
|
|
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):
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2016-07-15 16:28:45 -04:00
|
|
|
GET /_cluster/health?wait_for_status=yellow&timeout=50s
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
2016-07-15 16:28:45 -04:00
|
|
|
// CONSOLE
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
[float]
|
2013-09-25 12:17:40 -04:00
|
|
|
[[request-params]]
|
2013-08-28 19:24:34 -04:00
|
|
|
=== Request Parameters
|
|
|
|
|
|
|
|
The cluster health API accepts the following 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
|
2015-06-30 07:53:04 -04:00
|
|
|
provided or better, i.e. `green` > `yellow` > `red`. By default, will not
|
2014-06-20 12:04:51 -04:00
|
|
|
wait for any status.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2016-08-31 11:58:19 -04:00
|
|
|
`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.
|
2015-06-30 07:53:04 -04:00
|
|
|
|
2017-11-23 15:09:58 -05:00
|
|
|
`wait_for_no_initializing_shards`::
|
|
|
|
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.
|
|
|
|
|
2015-04-02 03:14:20 -04:00
|
|
|
`wait_for_active_shards`::
|
2016-08-31 11:58:19 -04:00
|
|
|
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`.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
`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`.
|
|
|
|
|
2015-12-11 19:26:33 -05:00
|
|
|
`local`::
|
|
|
|
If `true` returns the local node information and does not provide
|
|
|
|
the state from master node. Default: `false`.
|
|
|
|
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
The following is an example of getting the cluster health at the
|
|
|
|
`shards` level:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2016-07-15 16:28:45 -04:00
|
|
|
GET /_cluster/health/twitter?level=shards
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
2016-07-15 16:28:45 -04:00
|
|
|
// CONSOLE
|
|
|
|
// TEST[setup:twitter]
|