explain.asciidoc 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[ilm-explain-lifecycle]]
  4. === Explain Lifecycle API
  5. ++++
  6. <titleabbrev>Explain Lifecycle</titleabbrev>
  7. ++++
  8. beta[]
  9. Shows an index's current lifecycle status.
  10. ==== Request
  11. `GET <index>/_ilm/explain`
  12. ==== Description
  13. Retrieves information about the index's current lifecycle state, such as
  14. the currently executing phase, action, and step. Shows when the index entered
  15. each one, the definition of the running phase, and information
  16. about any failures.
  17. ==== Path Parameters
  18. `index` (required)::
  19. (string) Identifier for the index.
  20. ==== Request Parameters
  21. include::{docdir}/rest-api/timeoutparms.asciidoc[]
  22. ==== Authorization
  23. include::ilm-index-mgt-privilege.asciidoc[]
  24. ==== Examples
  25. The following example retrieves the lifecycle state of `my_index`:
  26. //////////////////////////
  27. [source,js]
  28. --------------------------------------------------
  29. PUT _ilm/policy/my_policy
  30. {
  31. "policy": {
  32. "phases": {
  33. "warm": {
  34. "min_age": "10d",
  35. "actions": {
  36. "forcemerge": {
  37. "max_num_segments": 1
  38. }
  39. }
  40. },
  41. "delete": {
  42. "min_age": "30d",
  43. "actions": {
  44. "delete": {}
  45. }
  46. }
  47. }
  48. }
  49. }
  50. PUT my_index
  51. {
  52. "settings": {
  53. "index.lifecycle.name": "my_policy",
  54. "index.number_of_replicas": 0
  55. }
  56. }
  57. GET /_cluster/health?wait_for_status=green&timeout=10s
  58. --------------------------------------------------
  59. // CONSOLE
  60. // TEST
  61. //////////////////////////
  62. [source,js]
  63. --------------------------------------------------
  64. GET my_index/_ilm/explain
  65. --------------------------------------------------
  66. // CONSOLE
  67. // TEST[continued]
  68. When management of the index is first taken over by ILM, `explain` shows
  69. that the index is managed and in the `new` phase:
  70. [source,js]
  71. --------------------------------------------------
  72. {
  73. "indices": {
  74. "my_index": {
  75. "index": "my_index",
  76. "managed": true, <1>
  77. "policy": "my_policy", <2>
  78. "lifecycle_date_millis": 1538475653281, <3>
  79. "phase": "new",
  80. "phase_time_millis": 1538475653317, <4>
  81. "action": "complete",
  82. "action_time_millis": 1538475653317, <5>
  83. "step": "complete",
  84. "step_time_millis": 1538475653317 <6>
  85. }
  86. }
  87. }
  88. --------------------------------------------------
  89. // CONSOLE
  90. // TESTRESPONSE[skip:no way to know if we will get this response immediately]
  91. <1> Shows if the index is being managed by ILM. If the index is not managed by
  92. ILM the other fields will not be shown
  93. <2> The name of the policy which ILM is using for this index
  94. <3> The timestamp used for the `min_age`
  95. <4> When the index entered the current phase
  96. <5> When the index entered the current action
  97. <6> When the index entered the current step
  98. Once the policy is running on the index, the response includes a
  99. `phase_execution` object that shows the definition of the current phase.
  100. Changes to the underlying policy will not affect this index until the current
  101. phase completes.
  102. [source,js]
  103. --------------------------------------------------
  104. {
  105. "indices": {
  106. "test-000069": {
  107. "index": "test-000069",
  108. "managed": true,
  109. "policy": "my_lifecycle3",
  110. "lifecycle_date_millis": 1538475653281,
  111. "lifecycle_date": "2018-10-15T13:45:21.981Z",
  112. "phase": "hot",
  113. "phase_time_millis": 1538475653317,
  114. "phase_time": "2018-10-15T13:45:22.577Z",
  115. "action": "rollover",
  116. "action_time_millis": 1538475653317,
  117. "action_time": "2018-10-15T13:45:22.577Z",
  118. "step": "attempt-rollover",
  119. "step_time_millis": 1538475653317,
  120. "step_time": "2018-10-15T13:45:22.577Z",
  121. "phase_execution": {
  122. "policy": "my_lifecycle3",
  123. "phase_definition": { <1>
  124. "min_age": "0ms",
  125. "actions": {
  126. "rollover": {
  127. "max_age": "30s"
  128. }
  129. }
  130. },
  131. "version": 3, <2>
  132. "modified_date": "2018-10-15T13:21:41.576Z", <3>
  133. "modified_date_in_millis": 1539609701576 <4>
  134. }
  135. }
  136. }
  137. }
  138. --------------------------------------------------
  139. // CONSOLE
  140. // TESTRESPONSE[skip:not possible to get the cluster into this state in a docs test]
  141. <1> The JSON phase definition loaded from the specified policy when the index
  142. entered this phase
  143. <2> The version of the policy that was loaded
  144. <3> The date the loaded policy was last modified
  145. <4> The epoch time when the loaded policy was last modified
  146. If {ILM} is waiting for a step to complete, the response includes status
  147. information for the step that's being performed on the index.
  148. [source,js]
  149. --------------------------------------------------
  150. {
  151. "indices": {
  152. "test-000020": {
  153. "index": "test-000020",
  154. "managed": true,
  155. "policy": "my_lifecycle3",
  156. "lifecycle_date_millis": 1538475653281,
  157. "lifecycle_date": "2018-10-15T13:45:21.981Z",
  158. "phase": "warm",
  159. "phase_time_millis": 1538475653317,
  160. "phase_time": "2018-10-15T13:45:22.577Z",
  161. "action": "allocate",
  162. "action_time_millis": 1538475653317,
  163. "action_time": "2018-10-15T13:45:22.577Z",
  164. "step": "check-allocation",
  165. "step_time_millis": 1538475653317,
  166. "step_time": "2018-10-15T13:45:22.577Z",
  167. "step_info": { <1>
  168. "message": "Waiting for all shard copies to be active",
  169. "shards_left_to_allocate": -1,
  170. "all_shards_active": false,
  171. "actual_replicas": 2
  172. },
  173. "phase_execution": {
  174. "policy": "my_lifecycle3",
  175. "phase_definition": {
  176. "min_age": "0ms",
  177. "actions": {
  178. "allocate": {
  179. "number_of_replicas": 2,
  180. "include": {
  181. "box_type": "warm"
  182. },
  183. "exclude": {},
  184. "require": {}
  185. },
  186. "forcemerge": {
  187. "max_num_segments": 1
  188. }
  189. }
  190. },
  191. "version": 2,
  192. "modified_date": "2018-10-15T13:20:02.489Z",
  193. "modified_date_in_millis": 1539609602489
  194. }
  195. }
  196. }
  197. }
  198. --------------------------------------------------
  199. // CONSOLE
  200. // TESTRESPONSE[skip:not possible to get the cluster into this state in a docs test]
  201. <1> Status of the step that's in progress.
  202. If the index is in the ERROR step, something went wrong while executing a
  203. step in the policy and and you will need to take action for the index to proceed
  204. to the next step. To help you diagnose the problem, the explain response shows
  205. the step that failed and the step info provides information about the error.
  206. [source,js]
  207. --------------------------------------------------
  208. {
  209. "indices": {
  210. "test-000056": {
  211. "index": "test-000056",
  212. "managed": true,
  213. "policy": "my_lifecycle3",
  214. "lifecycle_date_millis": 1538475653281,
  215. "lifecycle_date": "2018-10-15T13:45:21.981Z",
  216. "phase": "hot",
  217. "phase_time_millis": 1538475653317,
  218. "phase_time": "2018-10-15T13:45:22.577Z",
  219. "action": "rollover",
  220. "action_time_millis": 1538475653317,
  221. "action_time": "2018-10-15T13:45:22.577Z",
  222. "step": "ERROR",
  223. "step_time_millis": 1538475653317,
  224. "step_time": "2018-10-15T13:45:22.577Z",
  225. "failed_step": "attempt-rollover", <1>
  226. "step_info": { <2>
  227. "type": "resource_already_exists_exception",
  228. "reason": "index [test-000057/H7lF9n36Rzqa-KfKcnGQMg] already exists",
  229. "index_uuid": "H7lF9n36Rzqa-KfKcnGQMg",
  230. "index": "test-000057"
  231. },
  232. "phase_execution": {
  233. "policy": "my_lifecycle3",
  234. "phase_definition": {
  235. "min_age": "0ms",
  236. "actions": {
  237. "rollover": {
  238. "max_age": "30s"
  239. }
  240. }
  241. },
  242. "version": 3,
  243. "modified_date": "2018-10-15T13:21:41.576Z",
  244. "modified_date_in_millis": 1539609701576
  245. }
  246. }
  247. }
  248. }
  249. --------------------------------------------------
  250. // CONSOLE
  251. // TESTRESPONSE[skip:not possible to get the cluster into this state in a docs test]
  252. <1> The step that caused the error
  253. <2> What went wrong