state.asciidoc 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. [[cluster-state]]
  2. === Cluster state API
  3. ++++
  4. <titleabbrev>Cluster state</titleabbrev>
  5. ++++
  6. Returns metadata about the state of the cluster.
  7. [[cluster-state-api-request]]
  8. ==== {api-request-title}
  9. `GET /_cluster/state/<metrics>/<target>`
  10. [[cluster-state-api-prereqs]]
  11. ==== {api-prereq-title}
  12. * If the {es} {security-features} are enabled, you must have the `monitor` or
  13. `manage` <<privileges-list-cluster,cluster privilege>> to use this API.
  14. [[cluster-state-api-desc]]
  15. ==== {api-description-title}
  16. The cluster state API allows access to metadata representing the state of the
  17. whole cluster. This includes information such as
  18. * the set of nodes in the cluster
  19. * all cluster-level settings
  20. * information about the indices in the cluster, including their mappings and
  21. settings
  22. * the locations of all the shards in the cluster.
  23. NOTE: The response is an internal representation of the cluster state and its
  24. format may change from version to version. If possible, you should obtain any
  25. information from the cluster state using the other, more stable,
  26. <<cluster,cluster APIs>>.
  27. The response provides the cluster state itself, which can be filtered to only
  28. retrieve the parts of interest as described below.
  29. The cluster's `cluster_uuid` is also returned as part of the top-level response,
  30. in addition to the `metadata` section. added[6.4.0]
  31. NOTE: While the cluster is still forming, it is possible for the `cluster_uuid`
  32. to be `_na_` as well as the cluster state's version to be `-1`.
  33. By default, the cluster state request is routed to the master node, to ensure
  34. that the latest cluster state is returned. For debugging purposes, you can
  35. retrieve the cluster state local to a particular node by adding `local=true` to
  36. the query string.
  37. [[cluster-state-api-path-params]]
  38. ==== {api-path-parms-title}
  39. The cluster state contains information about all the indices in the cluster,
  40. including their mappings, as well as templates and other metadata. This means it
  41. can sometimes be quite large. To avoid the need to process all this information
  42. you can request only the part of the cluster state that you need:
  43. `<metrics>`::
  44. (Optional, string) A comma-separated list of the following options:
  45. +
  46. --
  47. `_all`::
  48. Shows all metrics.
  49. `blocks`::
  50. Shows the `blocks` part of the response.
  51. `master_node`::
  52. Shows the elected `master_node` part of the response.
  53. `metadata`::
  54. Shows the `metadata` part of the response. If you supply a comma separated
  55. list of indices, the returned output will only contain metadata for these
  56. indices.
  57. `nodes`::
  58. Shows the `nodes` part of the response.
  59. `routing_nodes`::
  60. Shows the `routing_nodes` part of the response.
  61. `routing_table`::
  62. Shows the `routing_table` part of the response. If you supply a comma
  63. separated list of indices, the returned output will only contain the
  64. routing table for these indices.
  65. `version`::
  66. Shows the cluster state version.
  67. --
  68. `<target>`::
  69. (Optional, string)
  70. Comma-separated list of data streams, indices, and index aliases used to limit
  71. the request. Wildcard expressions (`*`) are supported.
  72. +
  73. To target all data streams and indices in a cluster, omit this parameter or use
  74. `_all` or `*`.
  75. [[cluster-state-api-query-params]]
  76. ==== {api-query-parms-title}
  77. `allow_no_indices`::
  78. (Optional, Boolean) If `true`, the wildcard indices expression that resolves
  79. into no concrete indices will be ignored. (This includes `_all` string or
  80. when no indices have been specified).
  81. +
  82. Defaults to `true`.
  83. `expand_wildcards`::
  84. (Optional, string) Whether to expand wildcard expression to concrete indices
  85. that are open, closed or both. Available options: `open`, `closed`, `none`,
  86. `all`.
  87. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=flat-settings]
  88. `ignore_unavailable`::
  89. (Optional, Boolean) If `true`, unavailable indices (missing or closed) will
  90. be ignored.
  91. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=local]
  92. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=master-timeout]
  93. `wait_for_metadata_version`::
  94. (Optional, integer) Waits for the metadata version to be equal or greater
  95. than the specified metadata version.
  96. `wait_for_timeout`::
  97. (Optional, <<time-units, time units>>) Specifies the maximum time to wait
  98. for wait_for_metadata_version before timing out.
  99. [[cluster-state-api-example]]
  100. ==== {api-examples-title}
  101. The following example returns only `metadata` and `routing_table` data for the
  102. `foo` and `bar` data streams or indices:
  103. [source,console]
  104. --------------------------------------------------
  105. GET /_cluster/state/metadata,routing_table/foo,bar
  106. --------------------------------------------------
  107. The next example returns all available metadata for `foo` and `bar`:
  108. [source,console]
  109. --------------------------------------------------
  110. GET /_cluster/state/_all/foo,bar
  111. --------------------------------------------------
  112. This example returns only the `blocks` metadata:
  113. [source,console]
  114. --------------------------------------------------
  115. GET /_cluster/state/blocks
  116. --------------------------------------------------