state.asciidoc 4.6 KB

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