explain.asciidoc 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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 <<security-privileges>>.
  32. ==== Examples
  33. The following example retrieves the lifecycle state of `my_index`:
  34. //////////////////////////
  35. [source,console]
  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. // TEST
  68. //////////////////////////
  69. [source,console]
  70. --------------------------------------------------
  71. GET my_index/_ilm/explain
  72. --------------------------------------------------
  73. // TEST[continued]
  74. When management of the index is first taken over by ILM, `explain` shows
  75. that the index is managed and in the `new` phase:
  76. [source,console-result]
  77. --------------------------------------------------
  78. {
  79. "indices": {
  80. "my_index": {
  81. "index": "my_index",
  82. "managed": true, <1>
  83. "policy": "my_policy", <2>
  84. "lifecycle_date_millis": 1538475653281, <3>
  85. "age": "15s", <4>
  86. "phase": "new",
  87. "phase_time_millis": 1538475653317, <5>
  88. "action": "complete",
  89. "action_time_millis": 1538475653317, <6>
  90. "step": "complete",
  91. "step_time_millis": 1538475653317 <7>
  92. }
  93. }
  94. }
  95. --------------------------------------------------
  96. // TESTRESPONSE[skip:no way to know if we will get this response immediately]
  97. <1> Shows if the index is being managed by ILM. If the index is not managed by
  98. ILM the other fields will not be shown
  99. <2> The name of the policy which ILM is using for this index
  100. <3> The timestamp used for the `min_age`
  101. <4> The age of the index (used for calculating when to enter the next phase)
  102. <5> When the index entered the current phase
  103. <6> When the index entered the current action
  104. <7> When the index entered the current step
  105. Once the policy is running on the index, the response includes a
  106. `phase_execution` object that shows the definition of the current phase.
  107. Changes to the underlying policy will not affect this index until the current
  108. phase completes.
  109. [source,console-result]
  110. --------------------------------------------------
  111. {
  112. "indices": {
  113. "test-000069": {
  114. "index": "test-000069",
  115. "managed": true,
  116. "policy": "my_lifecycle3",
  117. "lifecycle_date_millis": 1538475653281,
  118. "lifecycle_date": "2018-10-15T13:45:21.981Z",
  119. "age": "25.14s",
  120. "phase": "hot",
  121. "phase_time_millis": 1538475653317,
  122. "phase_time": "2018-10-15T13:45:22.577Z",
  123. "action": "rollover",
  124. "action_time_millis": 1538475653317,
  125. "action_time": "2018-10-15T13:45:22.577Z",
  126. "step": "attempt-rollover",
  127. "step_time_millis": 1538475653317,
  128. "step_time": "2018-10-15T13:45:22.577Z",
  129. "phase_execution": {
  130. "policy": "my_lifecycle3",
  131. "phase_definition": { <1>
  132. "min_age": "0ms",
  133. "actions": {
  134. "rollover": {
  135. "max_age": "30s"
  136. }
  137. }
  138. },
  139. "version": 3, <2>
  140. "modified_date": "2018-10-15T13:21:41.576Z", <3>
  141. "modified_date_in_millis": 1539609701576 <4>
  142. }
  143. }
  144. }
  145. }
  146. --------------------------------------------------
  147. // TESTRESPONSE[skip:not possible to get the cluster into this state in a docs test]
  148. <1> The JSON phase definition loaded from the specified policy when the index
  149. entered this phase
  150. <2> The version of the policy that was loaded
  151. <3> The date the loaded policy was last modified
  152. <4> The epoch time when the loaded policy was last modified
  153. If {ilm-init} is waiting for a step to complete, the response includes status
  154. information for the step that's being performed on the index.
  155. [source,console-result]
  156. --------------------------------------------------
  157. {
  158. "indices": {
  159. "test-000020": {
  160. "index": "test-000020",
  161. "managed": true,
  162. "policy": "my_lifecycle3",
  163. "lifecycle_date_millis": 1538475653281,
  164. "lifecycle_date": "2018-10-15T13:45:21.981Z",
  165. "age": "4.12m",
  166. "phase": "warm",
  167. "phase_time_millis": 1538475653317,
  168. "phase_time": "2018-10-15T13:45:22.577Z",
  169. "action": "allocate",
  170. "action_time_millis": 1538475653317,
  171. "action_time": "2018-10-15T13:45:22.577Z",
  172. "step": "check-allocation",
  173. "step_time_millis": 1538475653317,
  174. "step_time": "2018-10-15T13:45:22.577Z",
  175. "step_info": { <1>
  176. "message": "Waiting for all shard copies to be active",
  177. "shards_left_to_allocate": -1,
  178. "all_shards_active": false,
  179. "actual_replicas": 2
  180. },
  181. "phase_execution": {
  182. "policy": "my_lifecycle3",
  183. "phase_definition": {
  184. "min_age": "0ms",
  185. "actions": {
  186. "allocate": {
  187. "number_of_replicas": 2,
  188. "include": {
  189. "box_type": "warm"
  190. },
  191. "exclude": {},
  192. "require": {}
  193. },
  194. "forcemerge": {
  195. "max_num_segments": 1
  196. }
  197. }
  198. },
  199. "version": 2,
  200. "modified_date": "2018-10-15T13:20:02.489Z",
  201. "modified_date_in_millis": 1539609602489
  202. }
  203. }
  204. }
  205. }
  206. --------------------------------------------------
  207. // TESTRESPONSE[skip:not possible to get the cluster into this state in a docs test]
  208. <1> Status of the step that's in progress.
  209. If the index is in the ERROR step, something went wrong while executing a
  210. step in the policy and you will need to take action for the index to proceed
  211. to the next step. To help you diagnose the problem, the explain response shows
  212. the step that failed and the step info provides information about the error.
  213. [source,console-result]
  214. --------------------------------------------------
  215. {
  216. "indices": {
  217. "test-000056": {
  218. "index": "test-000056",
  219. "managed": true,
  220. "policy": "my_lifecycle3",
  221. "lifecycle_date_millis": 1538475653281,
  222. "lifecycle_date": "2018-10-15T13:45:21.981Z",
  223. "age": "50.1d",
  224. "phase": "hot",
  225. "phase_time_millis": 1538475653317,
  226. "phase_time": "2018-10-15T13:45:22.577Z",
  227. "action": "rollover",
  228. "action_time_millis": 1538475653317,
  229. "action_time": "2018-10-15T13:45:22.577Z",
  230. "step": "ERROR",
  231. "step_time_millis": 1538475653317,
  232. "step_time": "2018-10-15T13:45:22.577Z",
  233. "failed_step": "attempt-rollover", <1>
  234. "step_info": { <2>
  235. "type": "resource_already_exists_exception",
  236. "reason": "index [test-000057/H7lF9n36Rzqa-KfKcnGQMg] already exists",
  237. "index_uuid": "H7lF9n36Rzqa-KfKcnGQMg",
  238. "index": "test-000057"
  239. },
  240. "phase_execution": {
  241. "policy": "my_lifecycle3",
  242. "phase_definition": {
  243. "min_age": "0ms",
  244. "actions": {
  245. "rollover": {
  246. "max_age": "30s"
  247. }
  248. }
  249. },
  250. "version": 3,
  251. "modified_date": "2018-10-15T13:21:41.576Z",
  252. "modified_date_in_millis": 1539609701576
  253. }
  254. }
  255. }
  256. }
  257. --------------------------------------------------
  258. // TESTRESPONSE[skip:not possible to get the cluster into this state in a docs test]
  259. <1> The step that caused the error
  260. <2> What went wrong