allocation-explain.asciidoc 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. [[cluster-allocation-explain]]
  2. === Cluster allocation explain API
  3. ++++
  4. <titleabbrev>Cluster allocation explain</titleabbrev>
  5. ++++
  6. Provides an explanation for a shard's current allocation.
  7. [source,console]
  8. ----
  9. GET _cluster/allocation/explain
  10. {
  11. "index": "my-index-000001",
  12. "shard": 0,
  13. "primary": false,
  14. "current_node": "my-node"
  15. }
  16. ----
  17. // TEST[setup:my_index]
  18. // TEST[s/"primary": false,/"primary": false/]
  19. // TEST[s/"current_node": "my-node"//]
  20. [[cluster-allocation-explain-api-request]]
  21. ==== {api-request-title}
  22. `GET _cluster/allocation/explain`
  23. [[cluster-allocation-explain-api-prereqs]]
  24. ==== {api-prereq-title}
  25. * If the {es} {security-features} are enabled, you must have the `monitor` or
  26. `manage` <<privileges-list-cluster,cluster privilege>> to use this API.
  27. [[cluster-allocation-explain-api-desc]]
  28. ==== {api-description-title}
  29. The purpose of the cluster allocation explain API is to provide
  30. explanations for shard allocations in the cluster. For unassigned shards,
  31. the explain API provides an explanation for why the shard is unassigned.
  32. For assigned shards, the explain API provides an explanation for why the
  33. shard is remaining on its current node and has not moved or rebalanced to
  34. another node. This API can be very useful when attempting to diagnose why a
  35. shard is unassigned or why a shard continues to remain on its current node when
  36. you might expect otherwise.
  37. [[cluster-allocation-explain-api-query-params]]
  38. ==== {api-query-parms-title}
  39. `include_disk_info`::
  40. (Optional, Boolean) If `true`, returns information about disk usage and
  41. shard sizes. Defaults to `false`.
  42. `include_yes_decisions`::
  43. (Optional, Boolean) If `true`, returns 'YES' decisions in explanation.
  44. Defaults to `false`.
  45. [[cluster-allocation-explain-api-request-body]]
  46. ==== {api-request-body-title}
  47. `current_node`::
  48. (Optional, string) Specifies the node ID or the name of the node to only
  49. explain a shard that is currently located on the specified node.
  50. `index`::
  51. (Optional, string) Specifies the name of the index that you would like an
  52. explanation for.
  53. `primary`::
  54. (Optional, Boolean) If `true`, returns explanation for the primary shard
  55. for the given shard ID.
  56. `shard`::
  57. (Optional, integer) Specifies the ID of the shard that you would like an
  58. explanation for.
  59. [[cluster-allocation-explain-api-examples]]
  60. ==== {api-examples-title}
  61. ===== Unassigned primary shard
  62. The following request gets an allocation explanation for an unassigned primary
  63. shard.
  64. ////
  65. [source,console]
  66. ----
  67. PUT my-index-000001?master_timeout=1s&timeout=1s
  68. {
  69. "settings": {
  70. "index.routing.allocation.include._name": "nonexistent_node",
  71. "index.routing.allocation.include._tier_preference": null
  72. }
  73. }
  74. ----
  75. ////
  76. [source,console]
  77. ----
  78. GET _cluster/allocation/explain
  79. {
  80. "index": "my-index-000001",
  81. "shard": 0,
  82. "primary": true
  83. }
  84. ----
  85. // TEST[continued]
  86. The API response indicates the shard is allocated to a nonexistent node.
  87. [source,console-result]
  88. ----
  89. {
  90. "index" : "my-index-000001",
  91. "shard" : 0,
  92. "primary" : true,
  93. "current_state" : "unassigned", <1>
  94. "unassigned_info" : {
  95. "reason" : "INDEX_CREATED", <2>
  96. "at" : "2017-01-04T18:08:16.600Z",
  97. "last_allocation_status" : "no"
  98. },
  99. "can_allocate" : "no", <3>
  100. "allocate_explanation" : "cannot allocate because allocation is not permitted to any of the nodes",
  101. "node_allocation_decisions" : [
  102. {
  103. "node_id" : "8qt2rY-pT6KNZB3-hGfLnw",
  104. "node_name" : "node-0",
  105. "transport_address" : "127.0.0.1:9401",
  106. "node_attributes" : {},
  107. "node_decision" : "no", <4>
  108. "weight_ranking" : 1,
  109. "deciders" : [
  110. {
  111. "decider" : "filter", <5>
  112. "decision" : "NO",
  113. "explanation" : "node does not match index setting [index.routing.allocation.include] filters [_name:\"nonexistent_node\"]" <6>
  114. }
  115. ]
  116. }
  117. ]
  118. }
  119. ----
  120. // TESTRESPONSE[s/"at" : "[^"]*"/"at" : $body.$_path/]
  121. // TESTRESPONSE[s/"node_id" : "[^"]*"/"node_id" : $body.$_path/]
  122. // TESTRESPONSE[s/"transport_address" : "[^"]*"/"transport_address" : $body.$_path/]
  123. // TESTRESPONSE[s/"node_attributes" : \{\}/"node_attributes" : $body.$_path/]
  124. <1> The current state of the shard.
  125. <2> The reason for the shard originally becoming unassigned.
  126. <3> Whether to allocate the shard.
  127. <4> Whether to allocate the shard to the particular node.
  128. <5> The decider which led to the `no` decision for the node.
  129. <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.
  130. The following response contains an allocation explanation for an unassigned
  131. primary shard that was previously allocated.
  132. [source,js]
  133. ----
  134. {
  135. "index" : "my-index-000001",
  136. "shard" : 0,
  137. "primary" : true,
  138. "current_state" : "unassigned",
  139. "unassigned_info" : {
  140. "reason" : "NODE_LEFT",
  141. "at" : "2017-01-04T18:03:28.464Z",
  142. "details" : "node_left[OIWe8UhhThCK0V5XfmdrmQ]",
  143. "last_allocation_status" : "no_valid_shard_copy"
  144. },
  145. "can_allocate" : "no_valid_shard_copy",
  146. "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"
  147. }
  148. ----
  149. // NOTCONSOLE
  150. ===== Unassigned replica shard
  151. The following response contains an allocation explanation for a replica that's
  152. unassigned due to <<delayed-allocation,delayed allocation>>.
  153. [source,js]
  154. ----
  155. {
  156. "index" : "my-index-000001",
  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" : "a copy of this shard is already allocated to this node [[my-index-000001][0], node[3sULLVJrRneSg0EfBB-2Ew], [P], s[STARTED], a[id=eV9P8BN1QPqRc3B4PLx6cg]]"
  193. }
  194. ]
  195. }
  196. ]
  197. }
  198. ----
  199. // NOTCONSOLE
  200. <1> The configured delay before allocating a replica shard that does not exist due to the node holding it leaving the cluster.
  201. <2> The remaining delay before allocating the replica shard.
  202. <3> Information about the shard data found on a node.
  203. ===== Assigned shard
  204. The following response contains an allocation explanation for an assigned shard.
  205. The response indicates the shard is not allowed to remain on its current node
  206. and must be reallocated.
  207. [source,js]
  208. ----
  209. {
  210. "index" : "my-index-000001",
  211. "shard" : 0,
  212. "primary" : true,
  213. "current_state" : "started",
  214. "current_node" : {
  215. "id" : "8lWJeJ7tSoui0bxrwuNhTA",
  216. "name" : "node_t1",
  217. "transport_address" : "127.0.0.1:9401"
  218. },
  219. "can_remain_on_current_node" : "no", <1>
  220. "can_remain_decisions" : [ <2>
  221. {
  222. "decider" : "filter",
  223. "decision" : "NO",
  224. "explanation" : "node does not match index setting [index.routing.allocation.include] filters [_name:\"nonexistent_node\"]"
  225. }
  226. ],
  227. "can_move_to_other_node" : "no", <3>
  228. "move_explanation" : "cannot move shard to another node, even though it is not allowed to remain on its current node",
  229. "node_allocation_decisions" : [
  230. {
  231. "node_id" : "_P8olZS8Twax9u6ioN-GGA",
  232. "node_name" : "node_t0",
  233. "transport_address" : "127.0.0.1:9400",
  234. "node_decision" : "no",
  235. "weight_ranking" : 1,
  236. "deciders" : [
  237. {
  238. "decider" : "filter",
  239. "decision" : "NO",
  240. "explanation" : "node does not match index setting [index.routing.allocation.include] filters [_name:\"nonexistent_node\"]"
  241. }
  242. ]
  243. }
  244. ]
  245. }
  246. ----
  247. // NOTCONSOLE
  248. <1> Whether the shard is allowed to remain on its current node.
  249. <2> The deciders that factored into the decision of why the shard is not allowed to remain on its current node.
  250. <3> Whether the shard is allowed to be allocated to another node.
  251. The following response contains an allocation explanation for a shard that must
  252. remain on its current node. Moving the shard to another node would not improve
  253. cluster balance.
  254. [source,js]
  255. ----
  256. {
  257. "index" : "my-index-000001",
  258. "shard" : 0,
  259. "primary" : true,
  260. "current_state" : "started",
  261. "current_node" : {
  262. "id" : "wLzJm4N4RymDkBYxwWoJsg",
  263. "name" : "node_t0",
  264. "transport_address" : "127.0.0.1:9400",
  265. "weight_ranking" : 1
  266. },
  267. "can_remain_on_current_node" : "yes",
  268. "can_rebalance_cluster" : "yes", <1>
  269. "can_rebalance_to_other_node" : "no", <2>
  270. "rebalance_explanation" : "cannot rebalance as no target node exists that can both allocate this shard and improve the cluster balance",
  271. "node_allocation_decisions" : [
  272. {
  273. "node_id" : "oE3EGFc8QN-Tdi5FFEprIA",
  274. "node_name" : "node_t1",
  275. "transport_address" : "127.0.0.1:9401",
  276. "node_decision" : "worse_balance", <3>
  277. "weight_ranking" : 1
  278. }
  279. ]
  280. }
  281. ----
  282. // NOTCONSOLE
  283. <1> Whether rebalancing is allowed on the cluster.
  284. <2> Whether the shard can be rebalanced to another node.
  285. <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.
  286. ===== No arguments
  287. If you call the API with no arguments, {es} retrieves an allocation explanation
  288. for an arbitrary unassigned primary or replica shard.
  289. [source,console]
  290. ----
  291. GET _cluster/allocation/explain
  292. ----
  293. // TEST[catch:bad_request]
  294. If the cluster contains no unassigned shards, the API returns a `400` error.