state.asciidoc 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. [[cluster-state]]
  2. === Cluster state API
  3. ++++
  4. <titleabbrev>Cluster state</titleabbrev>
  5. ++++
  6. .New API reference
  7. [sidebar]
  8. --
  9. For the most up-to-date API details, refer to {api-es}/group/endpoint-cluster[Cluster APIs].
  10. --
  11. Returns an internal representation of the cluster state for debugging or
  12. diagnostic purposes.
  13. [[cluster-state-api-request]]
  14. ==== {api-request-title}
  15. `GET /_cluster/state/<metrics>/<target>`
  16. [[cluster-state-api-prereqs]]
  17. ==== {api-prereq-title}
  18. * If the {es} {security-features} are enabled, you must have the `monitor` or
  19. `manage` <<privileges-list-cluster,cluster privilege>> to use this API.
  20. [[cluster-state-api-desc]]
  21. ==== {api-description-title}
  22. The _cluster state_ is an internal data structure which keeps track of a
  23. variety of information needed by every node, including:
  24. * The identity and attributes of the other nodes in the cluster
  25. * Cluster-wide settings
  26. * Index metadata, including the mapping and settings for each index
  27. * The location and status of every shard copy in the cluster
  28. The elected master node ensures that every node in the cluster has a copy of
  29. the same cluster state. The cluster state API lets you retrieve a
  30. representation of this internal state for debugging or diagnostic purposes. You
  31. may need to consult the {es} source code to determine the precise meaning of
  32. the response.
  33. By default the cluster state API will route requests to the elected master node
  34. since this node is the authoritative source of cluster states. You can also
  35. retrieve the cluster state held on the node handling the API request by adding
  36. the query parameter `?local=true`.
  37. {es} may need to expend significant effort to compute a response to this API in
  38. larger clusters, and the response may comprise a very large quantity of data.
  39. If you use this API repeatedly, your cluster may become unstable.
  40. [[cluster-state-api-unstable-warning]]
  41. WARNING: The response is a representation of an internal data structure. Its
  42. format is not subject to the same compatibility guarantees as other more stable
  43. APIs and may change from version to version. **Do not query this API using
  44. external monitoring tools.** Instead, obtain the information you require using
  45. other more stable <<cluster,cluster APIs>>.
  46. [[cluster-state-api-path-params]]
  47. ==== {api-path-parms-title}
  48. The cluster state can sometimes be very large, and {es} may consume significant
  49. resources while computing a response to this API. To reduce the size of the
  50. response, you can request only the part of the cluster state in which you are
  51. interested:
  52. `<metrics>`::
  53. (Optional, string) A comma-separated list of the following options:
  54. +
  55. --
  56. `_all`::
  57. Shows all metrics.
  58. `blocks`::
  59. Shows the `blocks` part of the response.
  60. `master_node`::
  61. Shows the `master_node` part of the response.
  62. `metadata`::
  63. Shows the `metadata` part of the response. If you supply a comma separated
  64. list of indices, the returned output will only contain metadata for these
  65. indices.
  66. `nodes`::
  67. Shows the `nodes` part of the response.
  68. `routing_nodes`::
  69. Shows the `routing_nodes` part of the response.
  70. `routing_table`::
  71. Shows the `routing_table` part of the response. If you supply a comma
  72. separated list of indices, the returned output will only contain the
  73. routing table for these indices.
  74. `version`::
  75. Shows the cluster state version.
  76. --
  77. `<target>`::
  78. (Optional, string) Comma-separated list of data streams, indices, and aliases
  79. used to limit the request. Supports wildcards (`*`). To target all data streams
  80. and indices, omit this parameter or use `*` or `_all`.
  81. [[cluster-state-api-query-params]]
  82. ==== {api-query-parms-title}
  83. `allow_no_indices`::
  84. (Optional, Boolean) If `true`, the wildcard indices expression that resolves
  85. into no concrete indices will be ignored. (This includes `_all` string or
  86. when no indices have been specified).
  87. +
  88. Defaults to `true`.
  89. `expand_wildcards`::
  90. (Optional, string) Whether to expand wildcard expression to concrete indices
  91. that are open, closed or both. Available options: `open`, `closed`, `none`,
  92. `all`.
  93. include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=flat-settings]
  94. `ignore_unavailable`::
  95. (Optional, Boolean) If `true`, unavailable indices (missing or closed) will
  96. be ignored.
  97. include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=local]
  98. include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=master-timeout]
  99. `wait_for_metadata_version`::
  100. (Optional, integer) Waits for the metadata version to be equal or greater
  101. than the specified metadata version.
  102. `wait_for_timeout`::
  103. (Optional, <<time-units, time units>>) Specifies the maximum time to wait
  104. for wait_for_metadata_version before timing out.
  105. [[cluster-state-api-example]]
  106. ==== {api-examples-title}
  107. The following example returns only `metadata` and `routing_table` data for the
  108. `foo` and `bar` data streams or indices:
  109. [source,console]
  110. --------------------------------------------------
  111. GET /_cluster/state/metadata,routing_table/foo,bar
  112. --------------------------------------------------
  113. The next example returns all available metadata for `foo` and `bar`:
  114. [source,console]
  115. --------------------------------------------------
  116. GET /_cluster/state/_all/foo,bar
  117. --------------------------------------------------
  118. This example returns only the `blocks` metadata:
  119. [source,console]
  120. --------------------------------------------------
  121. GET /_cluster/state/blocks
  122. --------------------------------------------------