2013-08-28 19:24:34 -04:00
|
|
|
[[cluster-state]]
|
2019-07-19 14:35:36 -04:00
|
|
|
=== Cluster State
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-03-18 05:12:03 -04:00
|
|
|
The cluster state API allows access to metadata representing the state of the
|
|
|
|
whole cluster. This includes information such as
|
|
|
|
|
|
|
|
* the set of nodes in the cluster
|
|
|
|
|
|
|
|
* all cluster-level settings
|
|
|
|
|
|
|
|
* information about the indices in the cluster, including their mappings and
|
|
|
|
settings
|
|
|
|
|
|
|
|
* the locations of all the shards in the cluster
|
|
|
|
|
|
|
|
The response is an internal representation of the cluster state and its format
|
|
|
|
may change from version to version. If possible, you should obtain any
|
|
|
|
information from the cluster state using the other, more stable,
|
|
|
|
<<cluster,cluster APIs>>.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2017-08-28 05:23:09 -04:00
|
|
|
GET /_cluster/state
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
2017-08-28 05:23:09 -04:00
|
|
|
// CONSOLE
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-03-18 05:12:03 -04:00
|
|
|
The response provides the cluster state itself, which can be filtered to only
|
|
|
|
retrieve the parts of interest as described below.
|
2017-03-02 14:20:29 -05:00
|
|
|
|
2019-03-18 05:12:03 -04:00
|
|
|
The cluster's `cluster_uuid` is also returned as part of the top-level response,
|
|
|
|
in addition to the `metadata` section. added[6.4.0]
|
2018-04-30 10:16:11 -04:00
|
|
|
|
|
|
|
NOTE: While the cluster is still forming, it is possible for the `cluster_uuid`
|
|
|
|
to be `_na_` as well as the cluster state's version to be `-1`.
|
|
|
|
|
2019-03-18 05:12:03 -04:00
|
|
|
By default, the cluster state request is routed to the master node, to ensure
|
|
|
|
that the latest cluster state is returned. For debugging purposes, you can
|
|
|
|
retrieve the cluster state local to a particular node by adding `local=true` to
|
|
|
|
the query string.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
[float]
|
2019-07-19 14:35:36 -04:00
|
|
|
==== Response Filters
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-03-18 05:12:03 -04:00
|
|
|
The cluster state contains information about all the indices in the cluster,
|
|
|
|
including their mappings, as well as templates and other metadata. This means it
|
|
|
|
can sometimes be quite large. To avoid the need to process all this information
|
|
|
|
you can request only the part of the cluster state that you need:
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2014-01-08 03:20:56 -05:00
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2019-03-18 05:12:03 -04:00
|
|
|
GET /_cluster/state/{metrics}
|
2017-08-28 05:23:09 -04:00
|
|
|
GET /_cluster/state/{metrics}/{indices}
|
2014-01-08 03:20:56 -05:00
|
|
|
--------------------------------------------------
|
2017-08-28 05:23:09 -04:00
|
|
|
// CONSOLE
|
2014-01-08 03:20:56 -05:00
|
|
|
|
2019-03-18 05:12:03 -04:00
|
|
|
`{metrics}` is a comma-separated list of the following options.
|
2014-01-08 03:20:56 -05:00
|
|
|
|
2014-02-09 20:24:03 -05:00
|
|
|
`version`::
|
|
|
|
Shows the cluster state version.
|
|
|
|
|
|
|
|
`master_node`::
|
|
|
|
Shows the elected `master_node` part of the response
|
|
|
|
|
2014-01-08 03:20:56 -05:00
|
|
|
`nodes`::
|
|
|
|
Shows the `nodes` part of the response
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2014-02-09 20:24:03 -05:00
|
|
|
`routing_table`::
|
2019-03-18 05:12:03 -04:00
|
|
|
Shows the `routing_table` part of the response. If you supply a comma
|
|
|
|
separated list of indices, the returned output will only contain the routing
|
|
|
|
table for these indices.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2014-01-08 03:20:56 -05:00
|
|
|
`metadata`::
|
2019-03-18 05:12:03 -04:00
|
|
|
Shows the `metadata` part of the response. If you supply a comma separated
|
|
|
|
list of indices, the returned output will only contain metadata for these
|
|
|
|
indices.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2014-01-08 03:20:56 -05:00
|
|
|
`blocks`::
|
2019-03-18 05:12:03 -04:00
|
|
|
Shows the `blocks` part of the response.
|
|
|
|
|
|
|
|
`_all`::
|
|
|
|
Shows all metrics.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-03-18 05:12:03 -04:00
|
|
|
The following example returns only `metadata` and `routing_table` data for the
|
|
|
|
`foo` and `bar` indices:
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2017-08-28 05:23:09 -04:00
|
|
|
GET /_cluster/state/metadata,routing_table/foo,bar
|
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
|
|
|
|
|
|
|
The next example returns everything for the `foo` and `bar` indices:
|
2014-01-08 03:20:56 -05:00
|
|
|
|
2017-08-28 05:23:09 -04:00
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
GET /_cluster/state/_all/foo,bar
|
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
2014-01-08 03:20:56 -05:00
|
|
|
|
2019-03-18 05:12:03 -04:00
|
|
|
Finally, this example return only the `blocks` metadata:
|
|
|
|
|
2017-08-28 05:23:09 -04:00
|
|
|
[source,js]
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
2017-08-28 05:23:09 -04:00
|
|
|
GET /_cluster/state/blocks
|
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
|
|
|
|
2014-01-08 03:20:56 -05:00
|
|
|
|