example-index-lifecycle-policy.asciidoc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. [role="xpack"]
  2. [[example-using-index-lifecycle-policy]]
  3. === Tutorial: Customize built-in {ilm-init} policies
  4. ++++
  5. <titleabbrev>Tutorial: Customize bult-in policies</titleabbrev>
  6. ++++
  7. {es} includes the following built-in {ilm-init} policies:
  8. - `logs`
  9. - `metrics`
  10. - `synthetics`
  11. {agent} uses these policies to manage backing indices for its data streams.
  12. This tutorial shows you how to use {kib}’s **Index Lifecycle Policies** to
  13. customize these policies based on your application's performance, resilience,
  14. and retention requirements.
  15. [discrete]
  16. [[example-using-index-lifecycle-policy-scenario]]
  17. ==== Scenario
  18. You want to send log files to an {es} cluster so you can visualize and analyze
  19. the data. This data has the following retention requirements:
  20. * When the write index reaches 50GB or is 30 days old, roll over to a new index.
  21. * After rollover, keep indices in the hot data tier for 30 days.
  22. * 30 days after rollover:
  23. ** Move indices to the warm data tier.
  24. ** Set replica shards to 1.
  25. ** <<indices-forcemerge, Force merge>> multiple index segments to free up the
  26. space used by deleted documents.
  27. * Delete indices 90 days after rollover.
  28. [discrete]
  29. [[example-using-index-lifecycle-policy-prerequisites]]
  30. ==== Prerequisites
  31. To complete this tutorial, you'll need:
  32. * An {es} cluster with hot and warm data tiers.
  33. ** {ess}:
  34. Elastic Stack deployments on {ess} include a hot tier by default. To add a warm
  35. tier, edit your deployment and click **Add capacity** for the warm data tier.
  36. +
  37. [role="screenshot"]
  38. image::images/ilm/tutorial-ilm-ess-add-warm-data-tier.png[Add a warm data tier to your deployment]
  39. ** Self-managed cluster:
  40. Assign `data_hot` and `data_warm` roles to nodes as described in
  41. <<data-tiers>>.
  42. +
  43. For example, include the `data_warm` node role in the `elasticsearch.yml` file
  44. of each node in the warm tier:
  45. +
  46. [source,yaml]
  47. ----
  48. node.roles: [ data_warm ]
  49. ----
  50. * A host with {agent} installed and configured to send logs to your {es}
  51. cluster.
  52. [discrete]
  53. [[example-using-index-lifecycle-policy-view-ilm-policy]]
  54. ==== View the policy
  55. {agent} uses data streams with an index pattern of `logs-*-*` to store log
  56. monitoring data. The built-in `logs` {ilm-init} policy automatically manages
  57. backing indices for these data streams.
  58. To view the `logs` policy in {kib}:
  59. . Open the menu and go to **Stack Management > Index Lifecycle Policies**.
  60. . Select the `logs` policy.
  61. The `logs` policy uses the recommended rollover defaults: Start writing to a new
  62. index when the current write index reaches 50GB or becomes 30 days old.
  63. To view or change the rollover settings, click **Advanced settings** for the hot
  64. phase. Then disable **Use recommended defaults** to display the rollover
  65. settings.
  66. [role="screenshot"]
  67. image::images/ilm/tutorial-ilm-hotphaserollover-default.png[View rollover defaults]
  68. [discrete]
  69. [[ilm-ex-modify-policy]]
  70. ==== Modify the policy
  71. The default `logs` policy is designed to prevent the creation of many tiny daily
  72. indices. You can modify the policy to meet your performance requirements and
  73. manage resource usage.
  74. . Activate the warm phase and click **Advanced settings**.
  75. +
  76. --
  77. .. Set **Move data into phase when** to **30 days old**. This moves indices to
  78. the warm tier 30 days after rollover.
  79. .. Enable **Set replicas** and change **Number of replicas** to **1**.
  80. .. Enable **Force merge data** and set **Number of segments** to **1**.
  81. [role="screenshot"]
  82. image::images/ilm/tutorial-ilm-modify-default-warm-phase-rollover.png[Add a warm phase with custom settings]
  83. --
  84. . In the warm phase, click the trash icon to enable the delete phase.
  85. +
  86. [role="screenshot"]
  87. image::images/ilm/tutorial-ilm-enable-delete-phase.png[Enable the delete phase]
  88. +
  89. In the delete phase, set **Move data into phase when** to **90 days old**. This
  90. deletes indices 90 days after rollover.
  91. +
  92. [role="screenshot"]
  93. image::images/ilm/tutorial-ilm-delete-rollover.png[Add a delete phase]
  94. . Click **Save Policy**.