state.asciidoc 5.3 KB

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