allocation-explain.asciidoc 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. [[cluster-allocation-explain]]
  2. == Cluster Allocation Explain API
  3. The cluster allocation explanation API is designed to assist in answering the
  4. question "why is this shard unassigned?". To explain the allocation (on
  5. unassigned state) of a shard, issue a request like:
  6. experimental[The cluster allocation explain API is new and should still be considered experimental. The API may change in ways that are not backwards compatible]
  7. [source,js]
  8. --------------------------------------------------
  9. $ curl -XGET 'http://localhost:9200/_cluster/allocation/explain' -d'{
  10. "index": "myindex",
  11. "shard": 0,
  12. "primary": false
  13. }'
  14. --------------------------------------------------
  15. Specify the `index` and `shard` id of the shard you would like an explanation
  16. for, as well as the `primary` flag to indicate whether to explain a primary or
  17. replica shard.
  18. The response looks like:
  19. [source,js]
  20. --------------------------------------------------
  21. {
  22. "shard" : {
  23. "index" : "myindex",
  24. "index_uuid" : "KnW0-zELRs6PK84l0r38ZA",
  25. "id" : 0,
  26. "primary" : false
  27. },
  28. "assigned" : false, <1>
  29. "shard_state_fetch_pending": false, <2>
  30. "unassigned_info" : {
  31. "reason" : "INDEX_CREATED", <3>
  32. "at" : "2016-03-22T20:04:23.620Z"
  33. },
  34. "allocation_delay_ms" : 0, <4>
  35. "remaining_delay_ms" : 0, <5>
  36. "nodes" : {
  37. "V-Spi0AyRZ6ZvKbaI3691w" : {
  38. "node_name" : "H5dfFeA",
  39. "node_attributes" : { <6>
  40. "bar" : "baz"
  41. },
  42. "store" : {
  43. "shard_copy" : "NONE" <7>
  44. },
  45. "final_decision" : "NO", <8>
  46. "final_explanation" : "the shard cannot be assigned because one or more allocation decider returns a 'NO' decision",
  47. "weight" : 0.06666675, <9>
  48. "decisions" : [ { <10>
  49. "decider" : "filter",
  50. "decision" : "NO",
  51. "explanation" : "node does not match index include filters [foo:\"bar\"]"
  52. } ]
  53. },
  54. "Qc6VL8c5RWaw1qXZ0Rg57g" : {
  55. "node_name" : "bGG90GE",
  56. "node_attributes" : {
  57. "bar" : "baz",
  58. "foo" : "bar"
  59. },
  60. "store" : {
  61. "shard_copy" : "AVAILABLE"
  62. },
  63. "final_decision" : "NO",
  64. "final_explanation" : "the shard cannot be assigned because one or more allocation decider returns a 'NO' decision",
  65. "weight" : -1.3833332,
  66. "decisions" : [ {
  67. "decider" : "same_shard",
  68. "decision" : "NO",
  69. "explanation" : "the shard cannot be allocated on the same node id [Qc6VL8c5RWaw1qXZ0Rg57g] on which it already exists"
  70. } ]
  71. },
  72. "PzdyMZGXQdGhqTJHF_hGgA" : {
  73. "node_name" : "DKDM97B",
  74. "node_attributes" : { },
  75. "store" : {
  76. "shard_copy" : "NONE"
  77. },
  78. "final_decision" : "NO",
  79. "final_explanation" : "the shard cannot be assigned because one or more allocation decider returns a 'NO' decision",
  80. "weight" : 2.3166666,
  81. "decisions" : [ {
  82. "decider" : "filter",
  83. "decision" : "NO",
  84. "explanation" : "node does not match index include filters [foo:\"bar\"]"
  85. } ]
  86. }
  87. }
  88. }
  89. --------------------------------------------------
  90. <1> Whether the shard is assigned or unassigned
  91. <2> Whether information about the shard is still being fetched
  92. <3> Reason for the shard originally becoming unassigned
  93. <4> Configured delay before the shard can be allocated
  94. <5> Remaining delay before the shard can be allocated
  95. <6> User-added attributes the node has
  96. <7> The shard copy information for this node and error (if applicable)
  97. <8> Final decision and explanation of whether the shard can be allocated to this node
  98. <9> Weight for how much the allocator would like to allocate the shard to this node
  99. <10> List of node decisions factoring into final decision about the shard
  100. For a shard that is already assigned, the output looks similar to:
  101. [source,js]
  102. --------------------------------------------------
  103. {
  104. "shard" : {
  105. "index" : "only-foo",
  106. "index_uuid" : "KnW0-zELRs6PK84l0r38ZA",
  107. "id" : 0,
  108. "primary" : true
  109. },
  110. "assigned" : true,
  111. "assigned_node_id" : "Qc6VL8c5RWaw1qXZ0Rg57g", <1>
  112. "shard_state_fetch_pending": false,
  113. "allocation_delay_ms" : 0,
  114. "remaining_delay_ms" : 0,
  115. "nodes" : {
  116. "V-Spi0AyRZ6ZvKbaI3691w" : {
  117. "node_name" : "bGG90GE",
  118. "node_attributes" : {
  119. "bar" : "baz"
  120. },
  121. "store" : {
  122. "shard_copy" : "NONE"
  123. },
  124. "final_decision" : "NO",
  125. "final_explanation" : "the shard cannot be assigned because one or more allocation decider returns a 'NO' decision",
  126. "weight" : 1.4499999,
  127. "decisions" : [ {
  128. "decider" : "filter",
  129. "decision" : "NO",
  130. "explanation" : "node does not match index include filters [foo:\"bar\"]"
  131. } ]
  132. },
  133. "Qc6VL8c5RWaw1qXZ0Rg57g" : {
  134. "node_name" : "I8hydUG",
  135. "node_attributes" : {
  136. "bar" : "baz",
  137. "foo" : "bar"
  138. },
  139. "store" : {
  140. "shard_copy" : "AVAILABLE"
  141. },
  142. "final_decision" : "ALREADY_ASSIGNED", <2>
  143. "final_explanation" : "the shard is already assigned to this node",
  144. "weight" : 0.0,
  145. "decisions" : [ {
  146. "decider" : "same_shard",
  147. "decision" : "NO",
  148. "explanation" : "the shard cannot be allocated on the same node id [Qc6VL8c5RWaw1qXZ0Rg57g] on which it already exists"
  149. } ]
  150. },
  151. "PzdyMZGXQdGhqTJHF_hGgA" : {
  152. "node_name" : "H5dfFeA",
  153. "node_attributes" : { },
  154. "store" : {
  155. "shard_copy" : "NONE"
  156. },
  157. "final_decision" : "NO",
  158. "final_explanation" : "the shard cannot be assigned because one or more allocation decider returns a 'NO' decision",
  159. "weight" : 3.6999998,
  160. "decisions" : [ {
  161. "decider" : "filter",
  162. "decision" : "NO",
  163. "explanation" : "node does not match index include filters [foo:\"bar\"]"
  164. } ]
  165. }
  166. }
  167. }
  168. --------------------------------------------------
  169. <1> Node the shard is currently assigned to
  170. <2> The decision is "ALREADY_ASSIGNED" because the shard is currently assigned to this node
  171. You can also have Elasticsearch explain the allocation of the first unassigned
  172. shard it finds by sending an empty body, such as:
  173. [source,js]
  174. --------------------------------------------------
  175. $ curl -XGET 'http://localhost:9200/_cluster/allocation/explain'
  176. --------------------------------------------------
  177. If you would like to include all decisions that were factored into the final
  178. decision, the `include_yes_decisions` parameter will return all decisions:
  179. [source,js]
  180. --------------------------------------------------
  181. $ curl -XGET 'http://localhost:9200/_cluster/allocation/explain?include_yes_decisions=true'
  182. --------------------------------------------------
  183. Additionally, you can return information gathered by the cluster info service
  184. about disk usage and shard sizes by setting the `include_disk_info` parameter to
  185. `true`:
  186. [source,js]
  187. --------------------------------------------------
  188. $ curl -XGET 'http://localhost:9200/_cluster/allocation/explain?include_disk_info=true'
  189. --------------------------------------------------