allocation-explain.asciidoc 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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. `POST _cluster/allocation/explain`
  24. [[cluster-allocation-explain-api-prereqs]]
  25. ==== {api-prereq-title}
  26. * If the {es} {security-features} are enabled, you must have the `monitor` or
  27. `manage` <<privileges-list-cluster,cluster privilege>> to use this API.
  28. [[cluster-allocation-explain-api-desc]]
  29. ==== {api-description-title}
  30. The purpose of the cluster allocation explain API is to provide
  31. explanations for shard allocations in the cluster. For unassigned shards,
  32. the explain API provides an explanation for why the shard is unassigned.
  33. For assigned shards, the explain API provides an explanation for why the
  34. shard is remaining on its current node and has not moved or rebalanced to
  35. another node. This API can be very useful when attempting to diagnose why a
  36. shard is unassigned or why a shard continues to remain on its current node when
  37. you might expect otherwise.
  38. [[cluster-allocation-explain-api-query-params]]
  39. ==== {api-query-parms-title}
  40. `include_disk_info`::
  41. (Optional, Boolean) If `true`, returns information about disk usage and
  42. shard sizes. Defaults to `false`.
  43. `include_yes_decisions`::
  44. (Optional, Boolean) If `true`, returns 'YES' decisions in explanation.
  45. Defaults to `false`.
  46. [[cluster-allocation-explain-api-request-body]]
  47. ==== {api-request-body-title}
  48. `current_node`::
  49. (Optional, string) Specifies the node ID or the name of the node currently
  50. holding the shard to explain. To explain an unassigned shard, omit this
  51. parameter.
  52. `index`::
  53. (Optional, string) Specifies the name of the index that you would like an
  54. explanation for.
  55. `primary`::
  56. (Optional, Boolean) If `true`, returns explanation for the primary shard
  57. for the given shard ID.
  58. `shard`::
  59. (Optional, integer) Specifies the ID of the shard that you would like an
  60. explanation for.
  61. [[cluster-allocation-explain-api-examples]]
  62. ==== {api-examples-title}
  63. ===== Unassigned primary shard
  64. The following request gets an allocation explanation for an unassigned primary
  65. shard.
  66. ////
  67. [source,console]
  68. ----
  69. PUT my-index-000001?master_timeout=1s&timeout=1s
  70. {
  71. "settings": {
  72. "index.routing.allocation.include._name": "nonexistent_node",
  73. "index.routing.allocation.include._tier_preference": null
  74. }
  75. }
  76. ----
  77. ////
  78. [source,console]
  79. ----
  80. GET _cluster/allocation/explain
  81. {
  82. "index": "my-index-000001",
  83. "shard": 0,
  84. "primary": true
  85. }
  86. ----
  87. // TEST[continued]
  88. The API response indicates the shard can only be allocated to a nonexistent
  89. node.
  90. [source,console-result]
  91. ----
  92. {
  93. "index" : "my-index-000001",
  94. "shard" : 0,
  95. "primary" : true,
  96. "current_state" : "unassigned", <1>
  97. "unassigned_info" : {
  98. "reason" : "INDEX_CREATED", <2>
  99. "at" : "2017-01-04T18:08:16.600Z",
  100. "last_allocation_status" : "no"
  101. },
  102. "can_allocate" : "no", <3>
  103. "allocate_explanation" : "Elasticsearch isn't allowed to allocate this shard to any of the nodes in the cluster. Choose a node to which you expect this shard to be allocated, find this node in the node-by-node explanation, and address the reasons which prevent Elasticsearch from allocating this shard there.",
  104. "node_allocation_decisions" : [
  105. {
  106. "node_id" : "8qt2rY-pT6KNZB3-hGfLnw",
  107. "node_name" : "node-0",
  108. "transport_address" : "127.0.0.1:9401",
  109. "roles" : ["data", "data_cold", "data_content", "data_frozen", "data_hot", "data_warm", "ingest", "master", "ml", "remote_cluster_client", "transform"],
  110. "node_attributes" : {},
  111. "node_decision" : "no", <4>
  112. "weight_ranking" : 1,
  113. "deciders" : [
  114. {
  115. "decider" : "filter", <5>
  116. "decision" : "NO",
  117. "explanation" : "node does not match index setting [index.routing.allocation.include] filters [_name:\"nonexistent_node\"]" <6>
  118. }
  119. ]
  120. }
  121. ]
  122. }
  123. ----
  124. // TESTRESPONSE[s/"at" : "[^"]*"/"at" : $body.$_path/]
  125. // TESTRESPONSE[s/"node_id" : "[^"]*"/"node_id" : $body.$_path/]
  126. // TESTRESPONSE[s/"transport_address" : "[^"]*"/"transport_address" : $body.$_path/]
  127. // TESTRESPONSE[s/"roles" : \[("[a-z_]*",)*("[a-z_]*")\]/"roles" : $body.$_path/]
  128. // TESTRESPONSE[s/"node_attributes" : \{\}/"node_attributes" : $body.$_path/]
  129. <1> The current state of the shard.
  130. <2> The reason for the shard originally becoming unassigned.
  131. <3> Whether to allocate the shard.
  132. <4> Whether to allocate the shard to the particular node.
  133. <5> The decider which led to the `no` decision for the node.
  134. <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.
  135. The following response contains an allocation explanation for an unassigned
  136. primary shard that was previously allocated.
  137. [source,js]
  138. ----
  139. {
  140. "index" : "my-index-000001",
  141. "shard" : 0,
  142. "primary" : true,
  143. "current_state" : "unassigned",
  144. "unassigned_info" : {
  145. "reason" : "NODE_LEFT",
  146. "at" : "2017-01-04T18:03:28.464Z",
  147. "details" : "node_left[OIWe8UhhThCK0V5XfmdrmQ]",
  148. "last_allocation_status" : "no_valid_shard_copy"
  149. },
  150. "can_allocate" : "no_valid_shard_copy",
  151. "allocate_explanation" : "Elasticsearch can't allocate this shard because there are no copies of its data in the cluster. Elasticsearch will allocate this shard when a node holding a good copy of its data joins the cluster. If no such node is available, restore this index from a recent snapshot."
  152. }
  153. ----
  154. // NOTCONSOLE
  155. ===== Unassigned replica shard
  156. The following response contains an allocation explanation for a replica that's
  157. unassigned due to <<delayed-allocation,delayed allocation>>.
  158. [source,js]
  159. ----
  160. {
  161. "index" : "my-index-000001",
  162. "shard" : 0,
  163. "primary" : false,
  164. "current_state" : "unassigned",
  165. "unassigned_info" : {
  166. "reason" : "NODE_LEFT",
  167. "at" : "2017-01-04T18:53:59.498Z",
  168. "details" : "node_left[G92ZwuuaRY-9n8_tc-IzEg]",
  169. "last_allocation_status" : "no_attempt"
  170. },
  171. "can_allocate" : "allocation_delayed",
  172. "allocate_explanation" : "The node containing this shard copy recently left the cluster. Elasticsearch is waiting for it to return. If the node does not return within [%s] then Elasticsearch will allocate this shard to another node. Please wait.",
  173. "configured_delay" : "1m", <1>
  174. "configured_delay_in_millis" : 60000,
  175. "remaining_delay" : "59.8s", <2>
  176. "remaining_delay_in_millis" : 59824,
  177. "node_allocation_decisions" : [
  178. {
  179. "node_id" : "pmnHu_ooQWCPEFobZGbpWw",
  180. "node_name" : "node_t2",
  181. "transport_address" : "127.0.0.1:9402",
  182. "roles" : ["data_content", "data_hot"],
  183. "node_decision" : "yes"
  184. },
  185. {
  186. "node_id" : "3sULLVJrRneSg0EfBB-2Ew",
  187. "node_name" : "node_t0",
  188. "transport_address" : "127.0.0.1:9400",
  189. "roles" : ["data_content", "data_hot"],
  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-000001][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. ===== Assigned shard
  211. The following response contains an allocation explanation for an assigned shard.
  212. The response indicates the shard is not allowed to remain on its current node
  213. and must be reallocated.
  214. [source,js]
  215. ----
  216. {
  217. "index" : "my-index-000001",
  218. "shard" : 0,
  219. "primary" : true,
  220. "current_state" : "started",
  221. "current_node" : {
  222. "id" : "8lWJeJ7tSoui0bxrwuNhTA",
  223. "name" : "node_t1",
  224. "transport_address" : "127.0.0.1:9401",
  225. "roles" : ["data_content", "data_hot"]
  226. },
  227. "can_remain_on_current_node" : "no", <1>
  228. "can_remain_decisions" : [ <2>
  229. {
  230. "decider" : "filter",
  231. "decision" : "NO",
  232. "explanation" : "node does not match index setting [index.routing.allocation.include] filters [_name:\"nonexistent_node\"]"
  233. }
  234. ],
  235. "can_move_to_other_node" : "no", <3>
  236. "move_explanation" : "This shard may not remain on its current node, but Elasticsearch isn't allowed to move it to another node. Choose a node to which you expect this shard to be allocated, find this node in the node-by-node explanation, and address the reasons which prevent Elasticsearch from allocating this shard there.",
  237. "node_allocation_decisions" : [
  238. {
  239. "node_id" : "_P8olZS8Twax9u6ioN-GGA",
  240. "node_name" : "node_t0",
  241. "transport_address" : "127.0.0.1:9400",
  242. "roles" : ["data_content", "data_hot"],
  243. "node_decision" : "no",
  244. "weight_ranking" : 1,
  245. "deciders" : [
  246. {
  247. "decider" : "filter",
  248. "decision" : "NO",
  249. "explanation" : "node does not match index setting [index.routing.allocation.include] filters [_name:\"nonexistent_node\"]"
  250. }
  251. ]
  252. }
  253. ]
  254. }
  255. ----
  256. // NOTCONSOLE
  257. <1> Whether the shard is allowed to remain on its current node.
  258. <2> The deciders that factored into the decision of why the shard is not allowed to remain on its current node.
  259. <3> Whether the shard is allowed to be allocated to another node.
  260. The following response contains an allocation explanation for a shard that must
  261. remain on its current node. Moving the shard to another node would not improve
  262. cluster balance.
  263. [source,js]
  264. ----
  265. {
  266. "index" : "my-index-000001",
  267. "shard" : 0,
  268. "primary" : true,
  269. "current_state" : "started",
  270. "current_node" : {
  271. "id" : "wLzJm4N4RymDkBYxwWoJsg",
  272. "name" : "node_t0",
  273. "transport_address" : "127.0.0.1:9400",
  274. "roles" : ["data_content", "data_hot"],
  275. "weight_ranking" : 1
  276. },
  277. "can_remain_on_current_node" : "yes",
  278. "can_rebalance_cluster" : "yes", <1>
  279. "can_rebalance_to_other_node" : "no", <2>
  280. "rebalance_explanation" : "Elasticsearch cannot rebalance this shard to another node since there is no node to which allocation is permitted which would improve the cluster balance. If you expect this shard to be rebalanced to another node, find this node in the node-by-node explanation and address the reasons which prevent Elasticsearch from rebalancing this shard there.",
  281. "node_allocation_decisions" : [
  282. {
  283. "node_id" : "oE3EGFc8QN-Tdi5FFEprIA",
  284. "node_name" : "node_t1",
  285. "transport_address" : "127.0.0.1:9401",
  286. "roles" : ["data_content", "data_hot"],
  287. "node_decision" : "worse_balance", <3>
  288. "weight_ranking" : 1
  289. }
  290. ]
  291. }
  292. ----
  293. // NOTCONSOLE
  294. <1> Whether rebalancing is allowed on the cluster.
  295. <2> Whether the shard can be rebalanced to another node.
  296. <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.
  297. ===== No arguments
  298. If you call the API with no arguments, {es} retrieves an allocation explanation
  299. for an arbitrary unassigned primary or replica shard.
  300. [source,console]
  301. ----
  302. GET _cluster/allocation/explain
  303. ----
  304. // TEST[catch:bad_request]
  305. If the cluster contains no unassigned shards, the API returns a `400` error.