explain.asciidoc 7.8 KB

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