explain.asciidoc 8.1 KB

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