explain.asciidoc 9.6 KB

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