explain.asciidoc 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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. "index_creation_date_millis": 1538475653281, <1>
  92. "time_since_index_creation": "15s", <2>
  93. "managed": true, <3>
  94. "policy": "my_policy", <4>
  95. "lifecycle_date_millis": 1538475653281, <5>
  96. "age": "15s", <6>
  97. "phase": "new",
  98. "phase_time_millis": 1538475653317, <7>
  99. "action": "complete"
  100. "action_time_millis": 1538475653317, <8>
  101. "step": "complete",
  102. "step_time_millis": 1538475653317 <9>
  103. }
  104. }
  105. }
  106. --------------------------------------------------
  107. // TESTRESPONSE[skip:no way to know if we will get this response immediately]
  108. <1> When the index was created, this timestamp is used to determine when to
  109. rollover
  110. <2> The time since the index creation (used for calculating when to rollover
  111. the index via the `max_age`)
  112. <3> Shows if the index is being managed by {ilm-init}. If the index is not managed by
  113. {ilm-init} the other fields will not be shown
  114. <4> The name of the policy which {ilm-init} is using for this index
  115. <5> The timestamp used for the `min_age`
  116. <6> The age of the index (used for calculating when to enter the next phase)
  117. <7> When the index entered the current phase
  118. <8> When the index entered the current action
  119. <9> When the index entered the current step
  120. Once the policy is running on the index, the response includes a
  121. `phase_execution` object that shows the definition of the current phase.
  122. Changes to the underlying policy will not affect this index until the current
  123. phase completes.
  124. [source,console-result]
  125. --------------------------------------------------
  126. {
  127. "indices": {
  128. "test-000069": {
  129. "index": "test-000069",
  130. "index_creation_date_millis": 1538475653281,
  131. "time_since_index_creation": "25.14s",
  132. "managed": true,
  133. "policy": "my_lifecycle3",
  134. "lifecycle_date_millis": 1538475653281,
  135. "lifecycle_date": "2018-10-15T13:45:21.981Z",
  136. "age": "25.14s",
  137. "phase": "hot",
  138. "phase_time_millis": 1538475653317,
  139. "phase_time": "2018-10-15T13:45:22.577Z",
  140. "action": "rollover",
  141. "action_time_millis": 1538475653317,
  142. "action_time": "2018-10-15T13:45:22.577Z",
  143. "step": "attempt-rollover",
  144. "step_time_millis": 1538475653317,
  145. "step_time": "2018-10-15T13:45:22.577Z",
  146. "phase_execution": {
  147. "policy": "my_lifecycle3",
  148. "phase_definition": { <1>
  149. "min_age": "0ms",
  150. "actions": {
  151. "rollover": {
  152. "max_age": "30s"
  153. }
  154. }
  155. },
  156. "version": 3, <2>
  157. "modified_date": "2018-10-15T13:21:41.576Z", <3>
  158. "modified_date_in_millis": 1539609701576 <4>
  159. }
  160. }
  161. }
  162. }
  163. --------------------------------------------------
  164. // TESTRESPONSE[skip:not possible to get the cluster into this state in a docs test]
  165. <1> The JSON phase definition loaded from the specified policy when the index
  166. entered this phase
  167. <2> The version of the policy that was loaded
  168. <3> The date the loaded policy was last modified
  169. <4> The epoch time when the loaded policy was last modified
  170. If {ilm-init} is waiting for a step to complete, the response includes status
  171. information for the step that's being performed on the index.
  172. [source,console-result]
  173. --------------------------------------------------
  174. {
  175. "indices": {
  176. "test-000020": {
  177. "index": "test-000020",
  178. "index_creation_date_millis": 1538475653281,
  179. "time_since_index_creation": "4.12m",
  180. "managed": true,
  181. "policy": "my_lifecycle3",
  182. "lifecycle_date_millis": 1538475653281,
  183. "lifecycle_date": "2018-10-15T13:45:21.981Z",
  184. "age": "4.12m",
  185. "phase": "warm",
  186. "phase_time_millis": 1538475653317,
  187. "phase_time": "2018-10-15T13:45:22.577Z",
  188. "action": "allocate",
  189. "action_time_millis": 1538475653317,
  190. "action_time": "2018-10-15T13:45:22.577Z",
  191. "step": "check-allocation",
  192. "step_time_millis": 1538475653317,
  193. "step_time": "2018-10-15T13:45:22.577Z",
  194. "step_info": { <1>
  195. "message": "Waiting for all shard copies to be active",
  196. "shards_left_to_allocate": -1,
  197. "all_shards_active": false,
  198. "number_of_replicas": 2
  199. },
  200. "phase_execution": {
  201. "policy": "my_lifecycle3",
  202. "phase_definition": {
  203. "min_age": "0ms",
  204. "actions": {
  205. "allocate": {
  206. "number_of_replicas": 2,
  207. "include": {
  208. "box_type": "warm"
  209. },
  210. "exclude": {},
  211. "require": {}
  212. },
  213. "forcemerge": {
  214. "max_num_segments": 1
  215. }
  216. }
  217. },
  218. "version": 2,
  219. "modified_date": "2018-10-15T13:20:02.489Z",
  220. "modified_date_in_millis": 1539609602489
  221. }
  222. }
  223. }
  224. }
  225. --------------------------------------------------
  226. // TESTRESPONSE[skip:not possible to get the cluster into this state in a docs test]
  227. <1> Status of the step that's in progress.
  228. If the index is in the ERROR step, something went wrong while executing a
  229. step in the policy and you will need to take action for the index to proceed
  230. to the next step. Some steps are safe to automatically be retried in certain
  231. circumstances. To help you diagnose the problem, the explain response shows
  232. the step that failed, the step info which provides information about the error,
  233. and information about the retry attempts executed for the failed step if it's
  234. the case.
  235. [source,console-result]
  236. --------------------------------------------------
  237. {
  238. "indices": {
  239. "test-000056": {
  240. "index": "test-000056",
  241. "index_creation_date_millis": 1538475653281,
  242. "time_since_index_creation": "50.1d",
  243. "managed": true,
  244. "policy": "my_lifecycle3",
  245. "lifecycle_date_millis": 1538475653281,
  246. "lifecycle_date": "2018-10-15T13:45:21.981Z",
  247. "age": "50.1d",
  248. "phase": "hot",
  249. "phase_time_millis": 1538475653317,
  250. "phase_time": "2018-10-15T13:45:22.577Z",
  251. "action": "rollover",
  252. "action_time_millis": 1538475653317,
  253. "action_time": "2018-10-15T13:45:22.577Z",
  254. "step": "ERROR",
  255. "step_time_millis": 1538475653317,
  256. "step_time": "2018-10-15T13:45:22.577Z",
  257. "failed_step": "check-rollover-ready", <1>
  258. "is_auto_retryable_error": true, <2>
  259. "failed_step_retry_count": 1, <3>
  260. "step_info": { <4>
  261. "type": "cluster_block_exception",
  262. "reason": "index [test-000057/H7lF9n36Rzqa-KfKcnGQMg] blocked by: [FORBIDDEN/5/index read-only (api)",
  263. "index_uuid": "H7lF9n36Rzqa-KfKcnGQMg",
  264. "index": "test-000057"
  265. },
  266. "phase_execution": {
  267. "policy": "my_lifecycle3",
  268. "phase_definition": {
  269. "min_age": "0ms",
  270. "actions": {
  271. "rollover": {
  272. "max_age": "30s"
  273. }
  274. }
  275. },
  276. "version": 3,
  277. "modified_date": "2018-10-15T13:21:41.576Z",
  278. "modified_date_in_millis": 1539609701576
  279. }
  280. }
  281. }
  282. }
  283. --------------------------------------------------
  284. // TESTRESPONSE[skip:not possible to get the cluster into this state in a docs test]
  285. <1> The step that caused the error
  286. <2> Indicates if retrying the failed step can overcome the error. If this
  287. is true, {ilm-init} will retry the failed step automatically.
  288. <3> Shows the number of attempted automatic retries to execute the failed
  289. step.
  290. <4> What went wrong