2013-08-28 19:24:34 -04:00
|
|
|
[[cluster-state]]
|
2019-10-22 13:27:31 -04:00
|
|
|
=== Cluster state API
|
|
|
|
++++
|
|
|
|
<titleabbrev>Cluster state</titleabbrev>
|
|
|
|
++++
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-08-08 04:23:17 -04:00
|
|
|
Returns metadata about the state of the cluster.
|
|
|
|
|
|
|
|
[[cluster-state-api-request]]
|
|
|
|
==== {api-request-title}
|
|
|
|
|
2020-07-02 17:20:55 -04:00
|
|
|
`GET /_cluster/state/<metrics>/<target>`
|
2019-08-08 04:23:17 -04:00
|
|
|
|
|
|
|
[[cluster-state-api-desc]]
|
|
|
|
==== {api-description-title}
|
|
|
|
|
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
|
|
|
|
|
2019-08-08 04:23:17 -04:00
|
|
|
* the locations of all the shards in the cluster.
|
2019-03-18 05:12:03 -04:00
|
|
|
|
2020-06-11 10:26:26 -04:00
|
|
|
NOTE: 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
|
2019-03-18 05:12:03 -04:00
|
|
|
information from the cluster state using the other, more stable,
|
|
|
|
<<cluster,cluster APIs>>.
|
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
|
|
|
|
2019-08-08 04:23:17 -04:00
|
|
|
[[cluster-state-api-path-params]]
|
|
|
|
==== {api-path-parms-title}
|
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
|
|
|
|
2019-08-23 10:57:20 -04:00
|
|
|
`<metrics>`::
|
2019-08-08 04:23:17 -04:00
|
|
|
(Optional, string) A comma-separated list of the following options:
|
|
|
|
+
|
|
|
|
--
|
|
|
|
`_all`::
|
|
|
|
Shows all metrics.
|
|
|
|
|
|
|
|
`blocks`::
|
|
|
|
Shows the `blocks` part of the response.
|
|
|
|
|
|
|
|
`master_node`::
|
|
|
|
Shows the elected `master_node` part of the response.
|
|
|
|
|
|
|
|
`metadata`::
|
|
|
|
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.
|
|
|
|
|
|
|
|
`nodes`::
|
|
|
|
Shows the `nodes` part of the response.
|
|
|
|
|
|
|
|
`routing_nodes`::
|
|
|
|
Shows the `routing_nodes` part of the response.
|
|
|
|
|
|
|
|
`routing_table`::
|
|
|
|
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.
|
|
|
|
|
|
|
|
`version`::
|
|
|
|
Shows the cluster state version.
|
|
|
|
--
|
|
|
|
|
2020-07-02 17:20:55 -04:00
|
|
|
`<target>`::
|
|
|
|
(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 `*`.
|
2019-08-08 04:23:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
[[cluster-state-api-query-params]]
|
|
|
|
==== {api-query-parms-title}
|
|
|
|
|
|
|
|
`allow_no_indices`::
|
|
|
|
(Optional, boolean) If `true`, the wildcard indices expression that resolves
|
|
|
|
into no concrete indices will be ignored. (This includes `_all` string or
|
|
|
|
when no indices have been specified).
|
2020-02-24 05:57:32 -05:00
|
|
|
+
|
|
|
|
Defaults to `true`.
|
2019-08-08 04:23:17 -04:00
|
|
|
|
|
|
|
`expand_wildcards`::
|
|
|
|
(Optional, string) Whether to expand wildcard expression to concrete indices
|
|
|
|
that are open, closed or both. Available options: `open`, `closed`, `none`,
|
|
|
|
`all`.
|
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=flat-settings]
|
2019-08-08 04:23:17 -04:00
|
|
|
|
|
|
|
`ignore_unavailable`::
|
|
|
|
(Optional, boolean) If `true`, unavailable indices (missing or closed) will
|
|
|
|
be ignored.
|
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=local]
|
2019-08-08 04:23:17 -04:00
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=master-timeout]
|
2019-08-08 04:23:17 -04:00
|
|
|
|
|
|
|
`wait_for_metadata_version`::
|
|
|
|
(Optional, integer) Waits for the metadata version to be equal or greater
|
|
|
|
than the specified metadata version.
|
|
|
|
|
|
|
|
`wait_for_timeout`::
|
|
|
|
(Optional, <<time-units, time units>>) Specifies the maximum time to wait
|
|
|
|
for wait_for_metadata_version before timing out.
|
|
|
|
|
|
|
|
|
|
|
|
[[cluster-state-api-example]]
|
|
|
|
==== {api-examples-title}
|
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
|
2020-07-02 17:20:55 -04:00
|
|
|
`foo` and `bar` data streams or indices:
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-09-09 13:38:14 -04:00
|
|
|
[source,console]
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
2017-08-28 05:23:09 -04:00
|
|
|
GET /_cluster/state/metadata,routing_table/foo,bar
|
|
|
|
--------------------------------------------------
|
|
|
|
|
2020-07-02 17:20:55 -04:00
|
|
|
The next example returns all available metadata for `foo` and `bar`:
|
2014-01-08 03:20:56 -05:00
|
|
|
|
2019-09-09 13:38:14 -04:00
|
|
|
[source,console]
|
2017-08-28 05:23:09 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
GET /_cluster/state/_all/foo,bar
|
|
|
|
--------------------------------------------------
|
2014-01-08 03:20:56 -05:00
|
|
|
|
2019-08-08 04:23:17 -04:00
|
|
|
This example returns only the `blocks` metadata:
|
2019-03-18 05:12:03 -04:00
|
|
|
|
2019-09-09 13:38:14 -04:00
|
|
|
[source,console]
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
2017-08-28 05:23:09 -04:00
|
|
|
GET /_cluster/state/blocks
|
|
|
|
--------------------------------------------------
|