ilm-with-existing-indices.asciidoc 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[ilm-with-existing-indices]]
  4. == Manage existing indices
  5. If you've been using Curator or some other mechanism to manage periodic indices,
  6. you have a couple options when migrating to {ilm-init}:
  7. * Set up your index templates to use an {ilm-init} policy to manage your new indices.
  8. Once {ilm-init} is managing your current write index, you can apply an appropriate policy to your old indices.
  9. * Reindex into an {ilm-init}-managed index.
  10. NOTE: Starting in Curator version 5.7, Curator ignores {ilm-init} managed indices.
  11. [discrete]
  12. [[ilm-existing-indices-apply]]
  13. === Apply policies to existing time series indices
  14. The simplest way to transition to managing your periodic indices with {ilm-init} is
  15. to <<apply-policy-template, configure an index template>> to apply a lifecycle policy to new indices.
  16. Once the index you are writing to is being managed by {ilm-init},
  17. you can <<apply-policy-multiple, manually apply a policy>> to your older indices.
  18. Define a separate policy for your older indices that omits the rollover action.
  19. Rollover is used to manage where new data goes, so isn't applicable.
  20. Keep in mind that policies applied to existing indices compare the `min_age` for each phase to
  21. the original creation date of the index, and might proceed through multiple phases immediately.
  22. If your policy performs resource-intensive operations like force merge,
  23. you don't want to have a lot of indices performing those operations all at once
  24. when you switch over to {ilm-init}.
  25. You can specify different `min_age` values in the policy you use for existing indices,
  26. or set <<index-lifecycle-origination-date, `index.lifecycle.origination_date`>>
  27. to control how the index age is calculated.
  28. Once all pre-{ilm-init} indices have been aged out and removed,
  29. you can delete the policy you used to manage them.
  30. NOTE: If you are using {beats} or {ls}, enabling {ilm-init} in version 7.0 and onward
  31. sets up {ilm-init} to manage new indices automatically.
  32. If you are using {beats} through {ls},
  33. you might need to change your {ls} output configuration and invoke the {beats} setup
  34. to use {ilm-init} for new data.
  35. [discrete]
  36. [[ilm-existing-indices-reindex]]
  37. === Reindex into a managed index
  38. An alternative to <<ilm-with-existing-periodic-indices,applying policies to existing indices>> is to
  39. reindex your data into an {ilm-init}-managed index.
  40. You might want to do this if creating periodic indices with very small amounts of data
  41. has led to excessive shard counts, or if continually indexing into the same index has led to large shards
  42. and performance issues.
  43. First, you need to set up the new {ilm-init}-managed index:
  44. . Update your index template to include the necessary {ilm-init} settings.
  45. . Bootstrap an initial index as the write index.
  46. . Stop writing to the old indices and index new documents using the alias that points to bootstrapped index.
  47. To reindex into the managed index:
  48. . Pause indexing new documents if you do not want to mix new and old data in the {ilm-init}-managed index.
  49. Mixing old and new data in one index is safe,
  50. but a combined index needs to be retained until you are ready to delete the new data.
  51. . Reduce the {ilm-init} poll interval to ensure that the index doesn't
  52. grow too large while waiting for the rollover check.
  53. By default, {ilm-init} checks to see what actions need to be taken every 10 minutes.
  54. +
  55. --
  56. [source,console]
  57. -----------------------
  58. PUT _cluster/settings
  59. {
  60. "transient": {
  61. "indices.lifecycle.poll_interval": "1m" <1>
  62. }
  63. }
  64. -----------------------
  65. // TEST[skip:don't want to overwrite this setting for other tests]
  66. <1> Check once a minute to see if {ilm-init} actions such as rollover need to be performed.
  67. --
  68. . Reindex your data using the <<docs-reindex,reindex API>>.
  69. If you want to partition the data in the order in which it was originally indexed,
  70. you can run separate reindex requests.
  71. +
  72. --
  73. IMPORTANT: Documents retain their original IDs. If you don't use automatically generated document IDs,
  74. and are reindexing from multiple source indices, you might need to do additional processing to
  75. ensure that document IDs don't conflict. One way to do this is to use a
  76. <<reindex-scripts,script>> in the reindex call to append the original index name
  77. to the document ID.
  78. //////////////////////////
  79. [source,console]
  80. -----------------------
  81. PUT _index_template/mylogs_template
  82. {
  83. "index_patterns": [
  84. "mylogs-*"
  85. ],
  86. "template": {
  87. "settings": {
  88. "number_of_shards": 1,
  89. "number_of_replicas": 1,
  90. "index": {
  91. "lifecycle": {
  92. "name": "mylogs_condensed_policy", <2>
  93. "rollover_alias": "mylogs" <3>
  94. }
  95. }
  96. },
  97. "mappings": {
  98. "properties": {
  99. "message": {
  100. "type": "text"
  101. },
  102. "@timestamp": {
  103. "type": "date"
  104. }
  105. }
  106. }
  107. }
  108. }
  109. -----------------------
  110. [source,console]
  111. -----------------------
  112. POST mylogs-pre-ilm-2019.06.24/_doc
  113. {
  114. "@timestamp": "2019-06-24T10:34:00",
  115. "message": "this is one log message"
  116. }
  117. -----------------------
  118. // TEST[continued]
  119. [source,console]
  120. -----------------------
  121. POST mylogs-pre-ilm-2019.06.25/_doc
  122. {
  123. "@timestamp": "2019-06-25T17:42:00",
  124. "message": "this is another log message"
  125. }
  126. -----------------------
  127. // TEST[continued]
  128. [source,console]
  129. --------------------------------------------------
  130. DELETE _index_template/mylogs_template
  131. --------------------------------------------------
  132. // TEST[continued]
  133. //////////////////////////
  134. [source,console]
  135. -----------------------
  136. POST _reindex
  137. {
  138. "source": {
  139. "index": "mylogs-*" <1>
  140. },
  141. "dest": {
  142. "index": "mylogs", <2>
  143. "op_type": "create" <3>
  144. }
  145. }
  146. -----------------------
  147. // TEST[continued]
  148. <1> Matches your existing indices. Using the prefix for
  149. the new indices makes using this index pattern much easier.
  150. <2> The alias that points to your bootstrapped index.
  151. <3> Halts reindexing if multiple documents have the same ID.
  152. This is recommended to prevent accidentally overwriting documents
  153. if documents in different source indices have the same ID.
  154. --
  155. . When reindexing is complete, set the {ilm-init} poll interval back to its default value to
  156. prevent unnecessary load on the master node:
  157. +
  158. [source,console]
  159. -----------------------
  160. PUT _cluster/settings
  161. {
  162. "transient": {
  163. "indices.lifecycle.poll_interval": null
  164. }
  165. }
  166. -----------------------
  167. // TEST[skip:don't want to overwrite this setting for other tests]
  168. . Resume indexing new data using the same alias.
  169. +
  170. Querying using this alias will now search your new data and all of the reindexed data.
  171. . Once you have verified that all of the reindexed data is available in the new managed indices,
  172. you can safely remove the old indices.