explain.asciidoc 8.0 KB

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