allocation-explain.asciidoc 11 KB

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