explain.asciidoc 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[ilm-explain]]
  4. === Explain Lifecycle API
  5. ++++
  6. <titleabbrev>Explain Lifecycle</titleabbrev>
  7. ++++
  8. Shows the current lifecycle status for an index.
  9. ==== Request
  10. `GET <index>/_ilm/explain`
  11. ==== Description
  12. This API returns information relating to the current lifecycle state of an
  13. index. This includes information such as the currently executing phase, action,
  14. and step and the timestamp when the index entered them. It also shows the
  15. definition of the current phase that is being run and in the event that there
  16. has been a failure, information regarding the failure.
  17. ==== Path Parameters
  18. `index` (required)::
  19. (string) Identifier for the index.
  20. ==== Request Parameters
  21. `timeout`::
  22. (time units) Specifies the period of time to wait for the completion of the
  23. GET operation. When this period of time elapses, the API fails and returns
  24. an error. The default value is `30s`. For more information about time units,
  25. see <<time-units>>.
  26. `master_timeout`::
  27. (time units) Specifies the period of time to wait for the connection with master.
  28. When this period of time elapses, the API fails and returns an error.
  29. The default value is `30s`. For more information about time units, see <<time-units>>.
  30. ==== Examples
  31. The following example retrieves the lifecycle state for the index `my_index`:
  32. //////////////////////////
  33. [source,js]
  34. --------------------------------------------------
  35. PUT _ilm/policy/my_policy
  36. {
  37. "policy": {
  38. "phases": {
  39. "warm": {
  40. "min_age": "10d",
  41. "actions": {
  42. "forcemerge": {
  43. "max_num_segments": 1
  44. }
  45. }
  46. },
  47. "delete": {
  48. "min_age": "30d",
  49. "actions": {
  50. "delete": {}
  51. }
  52. }
  53. }
  54. }
  55. }
  56. PUT my_index
  57. {
  58. "settings": {
  59. "index.lifecycle.name": "my_policy",
  60. "index.number_of_replicas": 0
  61. }
  62. }
  63. GET /_cluster/health?wait_for_status=green&timeout=10s
  64. --------------------------------------------------
  65. // CONSOLE
  66. // TEST
  67. //////////////////////////
  68. [source,js]
  69. --------------------------------------------------
  70. GET my_index/_ilm/explain
  71. --------------------------------------------------
  72. // CONSOLE
  73. // TEST[continued]
  74. When the index is first taken over by ILM you will see a response like the following:
  75. [source,js]
  76. --------------------------------------------------
  77. {
  78. "indices": {
  79. "my_index": {
  80. "index": "my_index",
  81. "managed": true, <1>
  82. "policy": "my_policy", <2>
  83. "lifecycle_date_millis": 1538475653281, <3>
  84. "phase": "new", <4>
  85. "phase_time_millis": 1538475653317, <5>
  86. "action": "complete", <6>
  87. "action_time_millis": 1538475653317, <7>
  88. "step": "complete", <8>
  89. "step_time_millis": 1538475653317 <9>
  90. }
  91. }
  92. }
  93. --------------------------------------------------
  94. // CONSOLE
  95. // TESTRESPONSE[s/"lifecycle_date_millis": 1538475653281/"lifecycle_date_millis": $body.indices.my_index.lifecycle_date_millis/]
  96. // TESTRESPONSE[s/"phase_time_millis": 1538475653317/"phase_time_millis": $body.indices.my_index.phase_time_millis/]
  97. // TESTRESPONSE[s/"action_time_millis": 1538475653317/"action_time_millis": $body.indices.my_index.action_time_millis/]
  98. // TESTRESPONSE[s/"step_time_millis": 1538475653317/"step_time_millis": $body.indices.my_index.step_time_millis/]
  99. <1> Shows if the index is being managed by ILM. If the index is not managed by
  100. ILM the other fields will not be shown
  101. <2> The name of the policy which ILM is using for this index
  102. <3> The timestamp used for the `min_age`
  103. <4> The current phase
  104. <5> The timestamp for when the index entered the current phase
  105. <6> The current action
  106. <7> The timestamp for when the index entered the current action
  107. <8> The current step
  108. <9> The timestamp for when the index entered the current step
  109. When the policy is running on the index the response will contain a
  110. `phase_execution` object that describes the exact phase that is being run.
  111. Changes to the underlying policy will not affect this index until the current
  112. phase definition has been completely executed.
  113. [source,js]
  114. --------------------------------------------------
  115. {
  116. "indices": {
  117. "test-000069": {
  118. "index": "test-000069",
  119. "managed": true,
  120. "policy": "my_lifecycle3",
  121. "lifecycle_date_millis": 1538475653281,
  122. "lifecycle_date": "2018-10-15T13:45:21.981Z",
  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": { <1>
  133. "policy": "my_lifecycle3", <2>
  134. "phase_definition": { <3>
  135. "min_age": "0ms",
  136. "actions": {
  137. "rollover": {
  138. "max_age": "30s"
  139. }
  140. }
  141. },
  142. "version": 3, <4>
  143. "modified_date": "2018-10-15T13:21:41.576Z", <5>
  144. "modified_date_in_millis": 1539609701576 <6>
  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 phase execution information for this index in its current phase
  153. <2> The policy that this phase definition was loaded from
  154. <3> The phase definition itself. This is the JSON for the phase loaded from the
  155. policy at the time the index entered the current phase
  156. <4> The version of the policy at the time the phase definition was loaded
  157. <5> The last modified date of the policy at the time the phase definition was loaded
  158. <6> The last modified epoch time of the policy at the time the phase definition was loaded
  159. If the policy is waiting for a step to complete for the index, the response will contain step information such as:
  160. [source,js]
  161. --------------------------------------------------
  162. {
  163. "indices": {
  164. "test-000020": {
  165. "index": "test-000020",
  166. "managed": true,
  167. "policy": "my_lifecycle3",
  168. "lifecycle_date_millis": 1538475653281,
  169. "lifecycle_date": "2018-10-15T13:45:21.981Z",
  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> `step_info` shows information about what ILM is waiting for on this index.
  214. In this case we are waiting for all shard copies of the index to be active.
  215. If the index is in the ERROR step, something has gone wrong when executing a
  216. step in the policy and will need to be investigated and resolved for the index
  217. to make progress. TO help determine how to resolve the error the explain response
  218. will show the step that failed in `failed_step`, and the information on the error
  219. that occurred in `step_info`.
  220. [source,js]
  221. --------------------------------------------------
  222. {
  223. "indices": {
  224. "test-000056": {
  225. "index": "test-000056",
  226. "managed": true,
  227. "policy": "my_lifecycle3",
  228. "lifecycle_date_millis": 1538475653281,
  229. "lifecycle_date": "2018-10-15T13:45:21.981Z",
  230. "phase": "hot",
  231. "phase_time_millis": 1538475653317,
  232. "phase_time": "2018-10-15T13:45:22.577Z",
  233. "action": "rollover",
  234. "action_time_millis": 1538475653317,
  235. "action_time": "2018-10-15T13:45:22.577Z",
  236. "step": "ERROR",
  237. "step_time_millis": 1538475653317,
  238. "step_time": "2018-10-15T13:45:22.577Z",
  239. "failed_step": "attempt_rollover", <1>
  240. "step_info": { <2>
  241. "type": "resource_already_exists_exception",
  242. "reason": "index [test-000057/H7lF9n36Rzqa-KfKcnGQMg] already exists",
  243. "index_uuid": "H7lF9n36Rzqa-KfKcnGQMg",
  244. "index": "test-000057"
  245. },
  246. "phase_execution": {
  247. "policy": "my_lifecycle3",
  248. "phase_definition": {
  249. "min_age": "0ms",
  250. "actions": {
  251. "rollover": {
  252. "max_age": "30s"
  253. }
  254. }
  255. },
  256. "version": 3,
  257. "modified_date": "2018-10-15T13:21:41.576Z",
  258. "modified_date_in_millis": 1539609701576
  259. }
  260. }
  261. }
  262. }
  263. --------------------------------------------------
  264. // CONSOLE
  265. // TESTRESPONSE[skip:not possible to get the cluster into this state in a docs test]
  266. <1> The step that caused an error
  267. <2> Information on the error that occurred. In this case the next index already
  268. existed when the rollover operation was performed