1
0

explain.asciidoc 9.5 KB

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