explain.asciidoc 8.5 KB

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