explain.asciidoc 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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[s/"lifecycle_date_millis": 1538475653281/"lifecycle_date_millis": $body.indices.my_index.lifecycle_date_millis/]
  90. // TESTRESPONSE[s/"phase_time_millis": 1538475653317/"phase_time_millis": $body.indices.my_index.phase_time_millis/]
  91. // TESTRESPONSE[s/"action_time_millis": 1538475653317/"action_time_millis": $body.indices.my_index.action_time_millis/]
  92. // TESTRESPONSE[s/"step_time_millis": 1538475653317/"step_time_millis": $body.indices.my_index.step_time_millis/]
  93. <1> Shows if the index is being managed by ILM. If the index is not managed by
  94. ILM the other fields will not be shown
  95. <2> The name of the policy which ILM is using for this index
  96. <3> The timestamp used for the `min_age`
  97. <4> When the index entered the current phase
  98. <5> When the index entered the current action
  99. <6> When the index entered the current step
  100. Once the policy is running on the index, the response includes a
  101. `phase_execution` object that shows the definition of the current phase.
  102. Changes to the underlying policy will not affect this index until the current
  103. phase completes.
  104. [source,js]
  105. --------------------------------------------------
  106. {
  107. "indices": {
  108. "test-000069": {
  109. "index": "test-000069",
  110. "managed": true,
  111. "policy": "my_lifecycle3",
  112. "lifecycle_date_millis": 1538475653281,
  113. "lifecycle_date": "2018-10-15T13:45:21.981Z",
  114. "phase": "hot",
  115. "phase_time_millis": 1538475653317,
  116. "phase_time": "2018-10-15T13:45:22.577Z",
  117. "action": "rollover",
  118. "action_time_millis": 1538475653317,
  119. "action_time": "2018-10-15T13:45:22.577Z",
  120. "step": "attempt_rollover",
  121. "step_time_millis": 1538475653317,
  122. "step_time": "2018-10-15T13:45:22.577Z",
  123. "phase_execution": {
  124. "policy": "my_lifecycle3",
  125. "phase_definition": { <1>
  126. "min_age": "0ms",
  127. "actions": {
  128. "rollover": {
  129. "max_age": "30s"
  130. }
  131. }
  132. },
  133. "version": 3, <2>
  134. "modified_date": "2018-10-15T13:21:41.576Z", <3>
  135. "modified_date_in_millis": 1539609701576 <4>
  136. }
  137. }
  138. }
  139. }
  140. --------------------------------------------------
  141. // CONSOLE
  142. // TESTRESPONSE[skip:not possible to get the cluster into this state in a docs test]
  143. <1> The JSON phase definition loaded from the specified policy when the index
  144. entered this phase
  145. <2> The version of the policy that was loaded
  146. <3> The date the loaded policy was last modified
  147. <4> The epoch time when the loaded policy was last modified
  148. If {ILM} is waiting for a step to complete, the response includes status
  149. information for the step that's being performed on the index.
  150. [source,js]
  151. --------------------------------------------------
  152. {
  153. "indices": {
  154. "test-000020": {
  155. "index": "test-000020",
  156. "managed": true,
  157. "policy": "my_lifecycle3",
  158. "lifecycle_date_millis": 1538475653281,
  159. "lifecycle_date": "2018-10-15T13:45:21.981Z",
  160. "phase": "warm",
  161. "phase_time_millis": 1538475653317,
  162. "phase_time": "2018-10-15T13:45:22.577Z",
  163. "action": "allocate",
  164. "action_time_millis": 1538475653317,
  165. "action_time": "2018-10-15T13:45:22.577Z",
  166. "step": "check-allocation",
  167. "step_time_millis": 1538475653317,
  168. "step_time": "2018-10-15T13:45:22.577Z",
  169. "step_info": { <1>
  170. "message": "Waiting for all shard copies to be active",
  171. "shards_left_to_allocate": -1,
  172. "all_shards_active": false,
  173. "actual_replicas": 2
  174. },
  175. "phase_execution": {
  176. "policy": "my_lifecycle3",
  177. "phase_definition": {
  178. "min_age": "0ms",
  179. "actions": {
  180. "allocate": {
  181. "number_of_replicas": 2,
  182. "include": {
  183. "box_type": "warm"
  184. },
  185. "exclude": {},
  186. "require": {}
  187. },
  188. "forcemerge": {
  189. "max_num_segments": 1
  190. }
  191. }
  192. },
  193. "version": 2,
  194. "modified_date": "2018-10-15T13:20:02.489Z",
  195. "modified_date_in_millis": 1539609602489
  196. }
  197. }
  198. }
  199. }
  200. --------------------------------------------------
  201. // CONSOLE
  202. // TESTRESPONSE[skip:not possible to get the cluster into this state in a docs test]
  203. <1> Status of the step that's in progress.
  204. If the index is in the ERROR step, something went wrong while executing a
  205. step in the policy and and you will need to take action for the index to proceed
  206. to the next step. To help you diagnose the problem, the explain response shows
  207. the step that failed and the step info provides information about the error.
  208. [source,js]
  209. --------------------------------------------------
  210. {
  211. "indices": {
  212. "test-000056": {
  213. "index": "test-000056",
  214. "managed": true,
  215. "policy": "my_lifecycle3",
  216. "lifecycle_date_millis": 1538475653281,
  217. "lifecycle_date": "2018-10-15T13:45:21.981Z",
  218. "phase": "hot",
  219. "phase_time_millis": 1538475653317,
  220. "phase_time": "2018-10-15T13:45:22.577Z",
  221. "action": "rollover",
  222. "action_time_millis": 1538475653317,
  223. "action_time": "2018-10-15T13:45:22.577Z",
  224. "step": "ERROR",
  225. "step_time_millis": 1538475653317,
  226. "step_time": "2018-10-15T13:45:22.577Z",
  227. "failed_step": "attempt_rollover", <1>
  228. "step_info": { <2>
  229. "type": "resource_already_exists_exception",
  230. "reason": "index [test-000057/H7lF9n36Rzqa-KfKcnGQMg] already exists",
  231. "index_uuid": "H7lF9n36Rzqa-KfKcnGQMg",
  232. "index": "test-000057"
  233. },
  234. "phase_execution": {
  235. "policy": "my_lifecycle3",
  236. "phase_definition": {
  237. "min_age": "0ms",
  238. "actions": {
  239. "rollover": {
  240. "max_age": "30s"
  241. }
  242. }
  243. },
  244. "version": 3,
  245. "modified_date": "2018-10-15T13:21:41.576Z",
  246. "modified_date_in_millis": 1539609701576
  247. }
  248. }
  249. }
  250. }
  251. --------------------------------------------------
  252. // CONSOLE
  253. // TESTRESPONSE[skip:not possible to get the cluster into this state in a docs test]
  254. <1> The step that caused the error
  255. <2> What went wrong