allocation-explain.asciidoc 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. [source,js]
  7. --------------------------------------------------
  8. $ curl -XGET 'http://localhost:9200/_cluster/allocation/explain' -d'{
  9. "index": "myindex",
  10. "shard": 0,
  11. "primary": false
  12. }'
  13. --------------------------------------------------
  14. Specify the `index` and `shard` id of the shard you would like an explanation
  15. for, as well as the `primary` flag to indicate whether to explain a primary or
  16. replica shard.
  17. The response looks like:
  18. [source,js]
  19. --------------------------------------------------
  20. {
  21. "shard" : {
  22. "index" : "myindex",
  23. "index_uuid" : "KnW0-zELRs6PK84l0r38ZA",
  24. "id" : 0,
  25. "primary" : false
  26. },
  27. "assigned" : false, <1>
  28. "unassigned_info" : {
  29. "reason" : "INDEX_CREATED", <2>
  30. "at" : "2016-03-22T20:04:23.620Z"
  31. },
  32. "nodes" : { <3>
  33. "V-Spi0AyRZ6ZvKbaI3691w" : {
  34. "node_name" : "node1",
  35. "node_attributes" : { <4>
  36. "bar" : "baz"
  37. },
  38. "final_decision" : "NO", <5>
  39. "weight" : 0.06666675, <6>
  40. "decisions" : [ { <7>
  41. "decider" : "filter",
  42. "decision" : "NO",
  43. "explanation" : "node does not match index include filters [foo:\"bar\"]"
  44. } ]
  45. },
  46. "Qc6VL8c5RWaw1qXZ0Rg57g" : {
  47. "node_name" : "node2",
  48. "node_attributes" : {
  49. "bar" : "baz",
  50. "foo" : "bar"
  51. },
  52. "final_decision" : "NO",
  53. "weight" : -1.3833332,
  54. "decisions" : [ {
  55. "decider" : "same_shard",
  56. "decision" : "NO",
  57. "explanation" : "the shard cannot be allocated on the same node id [Qc6VL8c5RWaw1qXZ0Rg57g] on which it already exists"
  58. } ]
  59. },
  60. "PzdyMZGXQdGhqTJHF_hGgA" : {
  61. "node_name" : "node3",
  62. "node_attributes" : { },
  63. "final_decision" : "NO",
  64. "weight" : 2.3166666,
  65. "decisions" : [ {
  66. "decider" : "filter",
  67. "decision" : "NO",
  68. "explanation" : "node does not match index include filters [foo:\"bar\"]"
  69. } ]
  70. }
  71. }
  72. }
  73. --------------------------------------------------
  74. <1> Whether the shard is assigned or unassigned
  75. <2> Reason for the shard originally becoming unassigned
  76. <3> List of node decisions about the shard
  77. <4> User-added attributes the node has
  78. <5> Final decision for whether the shard is allowed to be allocated to this node
  79. <6> Weight for how much the allocator would like to allocate the shard to this node
  80. <7> List of decisions factoring into final decision
  81. For a shard that is already assigned, the output looks similar to:
  82. [source,js]
  83. --------------------------------------------------
  84. {
  85. "shard" : {
  86. "index" : "only-foo",
  87. "index_uuid" : "KnW0-zELRs6PK84l0r38ZA",
  88. "id" : 0,
  89. "primary" : true
  90. },
  91. "assigned" : true,
  92. "assigned_node_id" : "Qc6VL8c5RWaw1qXZ0Rg57g", <1>
  93. "nodes" : {
  94. "V-Spi0AyRZ6ZvKbaI3691w" : {
  95. "node_name" : "Susan Storm",
  96. "node_attributes" : {
  97. "bar" : "baz"
  98. },
  99. "final_decision" : "NO",
  100. "weight" : 1.4499999,
  101. "decisions" : [ {
  102. "decider" : "filter",
  103. "decision" : "NO",
  104. "explanation" : "node does not match index include filters [foo:\"bar\"]"
  105. } ]
  106. },
  107. "Qc6VL8c5RWaw1qXZ0Rg57g" : {
  108. "node_name" : "Slipstream",
  109. "node_attributes" : {
  110. "bar" : "baz",
  111. "foo" : "bar"
  112. },
  113. "final_decision" : "CURRENTLY_ASSIGNED", <2>
  114. "weight" : 0.0,
  115. "decisions" : [ {
  116. "decider" : "same_shard",
  117. "decision" : "NO",
  118. "explanation" : "the shard cannot be allocated on the same node id [Qc6VL8c5RWaw1qXZ0Rg57g] on which it already exists"
  119. } ]
  120. },
  121. "PzdyMZGXQdGhqTJHF_hGgA" : {
  122. "node_name" : "The Symbiote",
  123. "node_attributes" : { },
  124. "final_decision" : "NO",
  125. "weight" : 3.6999998,
  126. "decisions" : [ {
  127. "decider" : "filter",
  128. "decision" : "NO",
  129. "explanation" : "node does not match index include filters [foo:\"bar\"]"
  130. } ]
  131. }
  132. }
  133. }
  134. --------------------------------------------------
  135. <1> Node the shard is currently assigned to
  136. <2> The decision is "CURRENTLY_ASSIGNED" because the shard is currently assigned to this node
  137. You can also have Elasticsearch explain the allocation of the first unassigned
  138. shard it finds by sending an empty body, such as:
  139. [source,js]
  140. --------------------------------------------------
  141. $ curl -XGET 'http://localhost:9200/_cluster/allocation/explain'
  142. --------------------------------------------------
  143. And if you would like to include all decisions that were factored into the final
  144. decision, the `include_yes_decisions` parameter will return all decisions:
  145. [source,js]
  146. --------------------------------------------------
  147. $ curl -XGET 'http://localhost:9200/_cluster/allocation/explain?include_yes_decisions=true'
  148. --------------------------------------------------