explain.asciidoc 9.6 KB

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