explain.asciidoc 11 KB

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