allocation-explain.asciidoc 11 KB

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