allocation-explain.asciidoc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. [[cluster-allocation-explain]]
  2. === Cluster allocation explain API
  3. ++++
  4. <titleabbrev>Cluster allocation explain</titleabbrev>
  5. ++++
  6. Provides explanations for shard allocations in the cluster.
  7. [[cluster-allocation-explain-api-request]]
  8. ==== {api-request-title}
  9. `GET /_cluster/allocation/explain`
  10. [[cluster-allocation-explain-api-desc]]
  11. ==== {api-description-title}
  12. The purpose of the cluster allocation explain API is to provide
  13. explanations for shard allocations in the cluster. For unassigned shards,
  14. the explain API provides an explanation for why the shard is unassigned.
  15. For assigned shards, the explain API provides an explanation for why the
  16. shard is remaining on its current node and has not moved or rebalanced to
  17. another node. This API can be very useful when attempting to diagnose why a
  18. shard is unassigned or why a shard continues to remain on its current node when
  19. you might expect otherwise.
  20. [[cluster-allocation-explain-api-query-params]]
  21. ==== {api-query-parms-title}
  22. `include_disk_info`::
  23. (Optional, boolean) If `true`, returns information about disk usage and
  24. shard sizes. Defaults to `false`.
  25. `include_yes_decisions`::
  26. (Optional, boolean) If `true`, returns 'YES' decisions in explanation.
  27. Defaults to `false`.
  28. [[cluster-allocation-explain-api-request-body]]
  29. ==== {api-request-body-title}
  30. `current_node`::
  31. (Optional, string) Specifies the node ID or the name of the node to only
  32. explain a shard that is currently located on the specified node.
  33. `index`::
  34. (Optional, string) Specifies the name of the index that you would like an
  35. explanation for.
  36. `primary`::
  37. (Optional, boolean) If `true`, returns explanation for the primary shard
  38. for the given shard ID.
  39. `shard`::
  40. (Optional, integer) Specifies the ID of the shard that you would like an
  41. explanation for.
  42. You can also have {es} explain the allocation of the first unassigned shard that
  43. it finds by sending an empty body for the request.
  44. [[cluster-allocation-explain-api-examples]]
  45. ==== {api-examples-title}
  46. //////
  47. [source,console]
  48. --------------------------------------------------
  49. PUT /myindex
  50. --------------------------------------------------
  51. // TESTSETUP
  52. //////
  53. [source,console]
  54. --------------------------------------------------
  55. GET /_cluster/allocation/explain
  56. {
  57. "index": "myindex",
  58. "shard": 0,
  59. "primary": true
  60. }
  61. --------------------------------------------------
  62. ===== Example of the current_node parameter
  63. [source,console]
  64. --------------------------------------------------
  65. GET /_cluster/allocation/explain
  66. {
  67. "index": "myindex",
  68. "shard": 0,
  69. "primary": false,
  70. "current_node": "nodeA" <1>
  71. }
  72. --------------------------------------------------
  73. // TEST[skip:no way of knowing the current_node]
  74. <1> The node where shard 0 currently has a replica on
  75. ===== Examples of unassigned primary shard explanations
  76. //////
  77. [source,console]
  78. --------------------------------------------------
  79. DELETE myindex
  80. --------------------------------------------------
  81. //////
  82. [source,console]
  83. --------------------------------------------------
  84. PUT /my_index?master_timeout=1s&timeout=1s
  85. {"settings": {"index.routing.allocation.include._name": "non_existent_node"} }
  86. GET /_cluster/allocation/explain
  87. {
  88. "index": "my_index",
  89. "shard": 0,
  90. "primary": true
  91. }
  92. --------------------------------------------------
  93. The API returns the following response for an unassigned primary shard:
  94. [source,console-result]
  95. --------------------------------------------------
  96. {
  97. "index" : "my_index",
  98. "shard" : 0,
  99. "primary" : true,
  100. "current_state" : "unassigned", <1>
  101. "unassigned_info" : {
  102. "reason" : "INDEX_CREATED", <2>
  103. "at" : "2017-01-04T18:08:16.600Z",
  104. "last_allocation_status" : "no"
  105. },
  106. "can_allocate" : "no", <3>
  107. "allocate_explanation" : "cannot allocate because allocation is not permitted to any of the nodes",
  108. "node_allocation_decisions" : [
  109. {
  110. "node_id" : "8qt2rY-pT6KNZB3-hGfLnw",
  111. "node_name" : "node-0",
  112. "transport_address" : "127.0.0.1:9401",
  113. "node_attributes" : {},
  114. "node_decision" : "no", <4>
  115. "weight_ranking" : 1,
  116. "deciders" : [
  117. {
  118. "decider" : "filter", <5>
  119. "decision" : "NO",
  120. "explanation" : "node does not match index setting [index.routing.allocation.include] filters [_name:\"non_existent_node\"]" <6>
  121. }
  122. ]
  123. }
  124. ]
  125. }
  126. --------------------------------------------------
  127. // TESTRESPONSE[s/"at" : "[^"]*"/"at" : $body.$_path/]
  128. // TESTRESPONSE[s/"node_id" : "[^"]*"/"node_id" : $body.$_path/]
  129. // TESTRESPONSE[s/"transport_address" : "[^"]*"/"transport_address" : $body.$_path/]
  130. // TESTRESPONSE[s/"node_attributes" : \{\}/"node_attributes" : $body.$_path/]
  131. <1> The current state of the shard.
  132. <2> The reason for the shard originally becoming unassigned.
  133. <3> Whether to allocate the shard.
  134. <4> Whether to allocate the shard to the particular node.
  135. <5> The decider which led to the `no` decision for the node.
  136. <6> An explanation as to why the decider returned a `no` decision, with a helpful hint pointing to the setting that led to the decision.
  137. The API response output for an unassigned primary shard that had previously been
  138. allocated to a node in the cluster:
  139. [source,js]
  140. --------------------------------------------------
  141. {
  142. "index" : "my_index",
  143. "shard" : 0,
  144. "primary" : true,
  145. "current_state" : "unassigned",
  146. "unassigned_info" : {
  147. "reason" : "NODE_LEFT",
  148. "at" : "2017-01-04T18:03:28.464Z",
  149. "details" : "node_left[OIWe8UhhThCK0V5XfmdrmQ]",
  150. "last_allocation_status" : "no_valid_shard_copy"
  151. },
  152. "can_allocate" : "no_valid_shard_copy",
  153. "allocate_explanation" : "cannot allocate because a previous copy of the primary shard existed but can no longer be found on the nodes in the cluster"
  154. }
  155. --------------------------------------------------
  156. // NOTCONSOLE
  157. ===== Example of an unassigned replica shard explanation
  158. The API response output for a replica that is unassigned due to delayed
  159. allocation:
  160. [source,js]
  161. --------------------------------------------------
  162. {
  163. "index" : "my_index",
  164. "shard" : 0,
  165. "primary" : false,
  166. "current_state" : "unassigned",
  167. "unassigned_info" : {
  168. "reason" : "NODE_LEFT",
  169. "at" : "2017-01-04T18:53:59.498Z",
  170. "details" : "node_left[G92ZwuuaRY-9n8_tc-IzEg]",
  171. "last_allocation_status" : "no_attempt"
  172. },
  173. "can_allocate" : "allocation_delayed",
  174. "allocate_explanation" : "cannot allocate because the cluster is still waiting 59.8s for the departed node holding a replica to rejoin, despite being allowed to allocate the shard to at least one other node",
  175. "configured_delay" : "1m", <1>
  176. "configured_delay_in_millis" : 60000,
  177. "remaining_delay" : "59.8s", <2>
  178. "remaining_delay_in_millis" : 59824,
  179. "node_allocation_decisions" : [
  180. {
  181. "node_id" : "pmnHu_ooQWCPEFobZGbpWw",
  182. "node_name" : "node_t2",
  183. "transport_address" : "127.0.0.1:9402",
  184. "node_decision" : "yes"
  185. },
  186. {
  187. "node_id" : "3sULLVJrRneSg0EfBB-2Ew",
  188. "node_name" : "node_t0",
  189. "transport_address" : "127.0.0.1:9400",
  190. "node_decision" : "no",
  191. "store" : { <3>
  192. "matching_size" : "4.2kb",
  193. "matching_size_in_bytes" : 4325
  194. },
  195. "deciders" : [
  196. {
  197. "decider" : "same_shard",
  198. "decision" : "NO",
  199. "explanation" : "a copy of this shard is already allocated to this node [[my_index][0], node[3sULLVJrRneSg0EfBB-2Ew], [P], s[STARTED], a[id=eV9P8BN1QPqRc3B4PLx6cg]]"
  200. }
  201. ]
  202. }
  203. ]
  204. }
  205. --------------------------------------------------
  206. // NOTCONSOLE
  207. <1> The configured delay before allocating a replica shard that does not exist due to the node holding it leaving the cluster.
  208. <2> The remaining delay before allocating the replica shard.
  209. <3> Information about the shard data found on a node.
  210. ===== Examples of allocated shard explanations
  211. The API response output for an assigned shard that is not allowed to remain on
  212. its current node and is required to move:
  213. [source,js]
  214. --------------------------------------------------
  215. {
  216. "index" : "my_index",
  217. "shard" : 0,
  218. "primary" : true,
  219. "current_state" : "started",
  220. "current_node" : {
  221. "id" : "8lWJeJ7tSoui0bxrwuNhTA",
  222. "name" : "node_t1",
  223. "transport_address" : "127.0.0.1:9401"
  224. },
  225. "can_remain_on_current_node" : "no", <1>
  226. "can_remain_decisions" : [ <2>
  227. {
  228. "decider" : "filter",
  229. "decision" : "NO",
  230. "explanation" : "node does not match index setting [index.routing.allocation.include] filters [_name:\"non_existent_node\"]"
  231. }
  232. ],
  233. "can_move_to_other_node" : "no", <3>
  234. "move_explanation" : "cannot move shard to another node, even though it is not allowed to remain on its current node",
  235. "node_allocation_decisions" : [
  236. {
  237. "node_id" : "_P8olZS8Twax9u6ioN-GGA",
  238. "node_name" : "node_t0",
  239. "transport_address" : "127.0.0.1:9400",
  240. "node_decision" : "no",
  241. "weight_ranking" : 1,
  242. "deciders" : [
  243. {
  244. "decider" : "filter",
  245. "decision" : "NO",
  246. "explanation" : "node does not match index setting [index.routing.allocation.include] filters [_name:\"non_existent_node\"]"
  247. }
  248. ]
  249. }
  250. ]
  251. }
  252. --------------------------------------------------
  253. // NOTCONSOLE
  254. <1> Whether the shard is allowed to remain on its current node.
  255. <2> The deciders that factored into the decision of why the shard is not allowed to remain on its current node.
  256. <3> Whether the shard is allowed to be allocated to another node.
  257. The API response output for an assigned shard that remains on its current node
  258. because moving the shard to another node does not form a better cluster balance:
  259. [source,js]
  260. --------------------------------------------------
  261. {
  262. "index" : "my_index",
  263. "shard" : 0,
  264. "primary" : true,
  265. "current_state" : "started",
  266. "current_node" : {
  267. "id" : "wLzJm4N4RymDkBYxwWoJsg",
  268. "name" : "node_t0",
  269. "transport_address" : "127.0.0.1:9400",
  270. "weight_ranking" : 1
  271. },
  272. "can_remain_on_current_node" : "yes",
  273. "can_rebalance_cluster" : "yes", <1>
  274. "can_rebalance_to_other_node" : "no", <2>
  275. "rebalance_explanation" : "cannot rebalance as no target node exists that can both allocate this shard and improve the cluster balance",
  276. "node_allocation_decisions" : [
  277. {
  278. "node_id" : "oE3EGFc8QN-Tdi5FFEprIA",
  279. "node_name" : "node_t1",
  280. "transport_address" : "127.0.0.1:9401",
  281. "node_decision" : "worse_balance", <3>
  282. "weight_ranking" : 1
  283. }
  284. ]
  285. }
  286. --------------------------------------------------
  287. // NOTCONSOLE
  288. <1> Whether rebalancing is allowed on the cluster.
  289. <2> Whether the shard can be rebalanced to another node.
  290. <3> The reason the shard cannot be rebalanced to the node, in this case indicating that it offers no better balance than the current node.