explain.asciidoc 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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. [[ilm-explain-lifecycle-request]]
  10. ==== {api-request-title}
  11. `GET <index>/_ilm/explain`
  12. [[ilm-explain-lifecycle-prereqs]]
  13. ==== {api-prereq-title}
  14. * If the {es} {security-features} are enabled, you must have the
  15. `view_index_metadata` or `manage_ilm` or both privileges on the indices being
  16. managed to use this API. For more information, see <<security-privileges>>.
  17. [[ilm-explain-lifecycle-desc]]
  18. ==== {api-description-title}
  19. Retrieves information about the index's current lifecycle state, such as
  20. the currently executing phase, action, and step. Shows when the index entered
  21. each one, the definition of the running phase, and information
  22. about any failures.
  23. [[ilm-explain-lifecycle-path-params]]
  24. ==== {api-path-parms-title}
  25. `<index>`::
  26. (Required, string) Identifier for the index.
  27. [[ilm-explain-lifecycle-query-params]]
  28. ==== {api-query-parms-title}
  29. `only_managed`::
  30. (Optional, boolean) Filters the returned indices to only indices that are managed by
  31. ILM.
  32. `only_errors`::
  33. (Optional, boolean) Filters the returned indices to only indices that are managed by
  34. ILM and are in an error state, either due to an encountering an error while
  35. executing the policy, or attempting to use a policy that does not exist.
  36. include::{docdir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
  37. [[ilm-explain-lifecycle-example]]
  38. ==== {api-examples-title}
  39. The following example retrieves the lifecycle state of `my_index`:
  40. //////////////////////////
  41. [source,console]
  42. --------------------------------------------------
  43. PUT _ilm/policy/my_policy
  44. {
  45. "policy": {
  46. "phases": {
  47. "warm": {
  48. "min_age": "10d",
  49. "actions": {
  50. "forcemerge": {
  51. "max_num_segments": 1
  52. }
  53. }
  54. },
  55. "delete": {
  56. "min_age": "30d",
  57. "actions": {
  58. "delete": {}
  59. }
  60. }
  61. }
  62. }
  63. }
  64. PUT my_index
  65. {
  66. "settings": {
  67. "index.lifecycle.name": "my_policy",
  68. "index.number_of_replicas": 0
  69. }
  70. }
  71. GET /_cluster/health?wait_for_status=green&timeout=10s
  72. --------------------------------------------------
  73. // TEST
  74. //////////////////////////
  75. [source,console]
  76. --------------------------------------------------
  77. GET my_index/_ilm/explain
  78. --------------------------------------------------
  79. // TEST[continued]
  80. When management of the index is first taken over by ILM, `explain` shows
  81. that the index is managed and in the `new` phase:
  82. [source,console-result]
  83. --------------------------------------------------
  84. {
  85. "indices": {
  86. "my_index": {
  87. "index": "my_index",
  88. "managed": true, <1>
  89. "policy": "my_policy", <2>
  90. "lifecycle_date_millis": 1538475653281, <3>
  91. "age": "15s", <4>
  92. "phase": "new",
  93. "phase_time_millis": 1538475653317, <5>
  94. "action": "complete",
  95. "action_time_millis": 1538475653317, <6>
  96. "step": "complete",
  97. "step_time_millis": 1538475653317 <7>
  98. }
  99. }
  100. }
  101. --------------------------------------------------
  102. // TESTRESPONSE[skip:no way to know if we will get this response immediately]
  103. <1> Shows if the index is being managed by ILM. If the index is not managed by
  104. ILM the other fields will not be shown
  105. <2> The name of the policy which ILM is using for this index
  106. <3> The timestamp used for the `min_age`
  107. <4> The age of the index (used for calculating when to enter the next phase)
  108. <5> When the index entered the current phase
  109. <6> When the index entered the current action
  110. <7> When the index entered the current step
  111. Once the policy is running on the index, the response includes a
  112. `phase_execution` object that shows the definition of the current phase.
  113. Changes to the underlying policy will not affect this index until the current
  114. phase completes.
  115. [source,console-result]
  116. --------------------------------------------------
  117. {
  118. "indices": {
  119. "test-000069": {
  120. "index": "test-000069",
  121. "managed": true,
  122. "policy": "my_lifecycle3",
  123. "lifecycle_date_millis": 1538475653281,
  124. "lifecycle_date": "2018-10-15T13:45:21.981Z",
  125. "age": "25.14s",
  126. "phase": "hot",
  127. "phase_time_millis": 1538475653317,
  128. "phase_time": "2018-10-15T13:45:22.577Z",
  129. "action": "rollover",
  130. "action_time_millis": 1538475653317,
  131. "action_time": "2018-10-15T13:45:22.577Z",
  132. "step": "attempt-rollover",
  133. "step_time_millis": 1538475653317,
  134. "step_time": "2018-10-15T13:45:22.577Z",
  135. "phase_execution": {
  136. "policy": "my_lifecycle3",
  137. "phase_definition": { <1>
  138. "min_age": "0ms",
  139. "actions": {
  140. "rollover": {
  141. "max_age": "30s"
  142. }
  143. }
  144. },
  145. "version": 3, <2>
  146. "modified_date": "2018-10-15T13:21:41.576Z", <3>
  147. "modified_date_in_millis": 1539609701576 <4>
  148. }
  149. }
  150. }
  151. }
  152. --------------------------------------------------
  153. // TESTRESPONSE[skip:not possible to get the cluster into this state in a docs test]
  154. <1> The JSON phase definition loaded from the specified policy when the index
  155. entered this phase
  156. <2> The version of the policy that was loaded
  157. <3> The date the loaded policy was last modified
  158. <4> The epoch time when the loaded policy was last modified
  159. If {ilm-init} is waiting for a step to complete, the response includes status
  160. information for the step that's being performed on the index.
  161. [source,console-result]
  162. --------------------------------------------------
  163. {
  164. "indices": {
  165. "test-000020": {
  166. "index": "test-000020",
  167. "managed": true,
  168. "policy": "my_lifecycle3",
  169. "lifecycle_date_millis": 1538475653281,
  170. "lifecycle_date": "2018-10-15T13:45:21.981Z",
  171. "age": "4.12m",
  172. "phase": "warm",
  173. "phase_time_millis": 1538475653317,
  174. "phase_time": "2018-10-15T13:45:22.577Z",
  175. "action": "allocate",
  176. "action_time_millis": 1538475653317,
  177. "action_time": "2018-10-15T13:45:22.577Z",
  178. "step": "check-allocation",
  179. "step_time_millis": 1538475653317,
  180. "step_time": "2018-10-15T13:45:22.577Z",
  181. "step_info": { <1>
  182. "message": "Waiting for all shard copies to be active",
  183. "shards_left_to_allocate": -1,
  184. "all_shards_active": false,
  185. "actual_replicas": 2
  186. },
  187. "phase_execution": {
  188. "policy": "my_lifecycle3",
  189. "phase_definition": {
  190. "min_age": "0ms",
  191. "actions": {
  192. "allocate": {
  193. "number_of_replicas": 2,
  194. "include": {
  195. "box_type": "warm"
  196. },
  197. "exclude": {},
  198. "require": {}
  199. },
  200. "forcemerge": {
  201. "max_num_segments": 1
  202. }
  203. }
  204. },
  205. "version": 2,
  206. "modified_date": "2018-10-15T13:20:02.489Z",
  207. "modified_date_in_millis": 1539609602489
  208. }
  209. }
  210. }
  211. }
  212. --------------------------------------------------
  213. // TESTRESPONSE[skip:not possible to get the cluster into this state in a docs test]
  214. <1> Status of the step that's in progress.
  215. If the index is in the ERROR step, something went wrong while executing a
  216. step in the policy and you will need to take action for the index to proceed
  217. to the next step. Some steps are safe to automatically be retried in certain
  218. circumstances. To help you diagnose the problem, the explain response shows
  219. the step that failed, the step info which provides information about the error,
  220. and information about the retry attempts executed for the failed step if it's
  221. the case.
  222. [source,console-result]
  223. --------------------------------------------------
  224. {
  225. "indices": {
  226. "test-000056": {
  227. "index": "test-000056",
  228. "managed": true,
  229. "policy": "my_lifecycle3",
  230. "lifecycle_date_millis": 1538475653281,
  231. "lifecycle_date": "2018-10-15T13:45:21.981Z",
  232. "age": "50.1d",
  233. "phase": "hot",
  234. "phase_time_millis": 1538475653317,
  235. "phase_time": "2018-10-15T13:45:22.577Z",
  236. "action": "rollover",
  237. "action_time_millis": 1538475653317,
  238. "action_time": "2018-10-15T13:45:22.577Z",
  239. "step": "ERROR",
  240. "step_time_millis": 1538475653317,
  241. "step_time": "2018-10-15T13:45:22.577Z",
  242. "failed_step": "check-rollover-ready", <1>
  243. "is_auto_retryable_error": true, <2>
  244. "failed_step_retry_count": 1, <3>
  245. "step_info": { <4>
  246. "type": "cluster_block_exception",
  247. "reason": "index [test-000057/H7lF9n36Rzqa-KfKcnGQMg] blocked by: [FORBIDDEN/5/index read-only (api)",
  248. "index_uuid": "H7lF9n36Rzqa-KfKcnGQMg",
  249. "index": "test-000057"
  250. },
  251. "phase_execution": {
  252. "policy": "my_lifecycle3",
  253. "phase_definition": {
  254. "min_age": "0ms",
  255. "actions": {
  256. "rollover": {
  257. "max_age": "30s"
  258. }
  259. }
  260. },
  261. "version": 3,
  262. "modified_date": "2018-10-15T13:21:41.576Z",
  263. "modified_date_in_millis": 1539609701576
  264. }
  265. }
  266. }
  267. }
  268. --------------------------------------------------
  269. // TESTRESPONSE[skip:not possible to get the cluster into this state in a docs test]
  270. <1> The step that caused the error
  271. <2> Indicates if retrying the failed step can overcome the error. If this
  272. is true, ILM will retry the failed step automatically.
  273. <3> Shows the number of attempted automatic retries to execute the failed
  274. step.
  275. <4> What went wrong