example-index-lifecycle-policy.asciidoc 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. [role="xpack"]
  2. [[example-using-index-lifecycle-policy]]
  3. === Tutorial: Customize built-in {ilm-init} policies
  4. ++++
  5. <titleabbrev>Customize built-in {ilm-init} policies</titleabbrev>
  6. ++++
  7. {es} includes the following built-in {ilm-init} policies:
  8. * `logs`
  9. * `metrics`
  10. * `synthetics`
  11. The {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 <<glossary-replica-shard, 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 the {ess} include a hot tier by default. To add a
  35. warm tier, edit your deployment and click **Add capacity** for the warm data
  36. tier.
  37. +
  38. [role="screenshot"]
  39. image::images/ilm/tutorial-ilm-ess-add-warm-data-tier.png[Add a warm data tier to your deployment]
  40. ** Self-managed cluster:
  41. Assign `data_hot` and `data_warm` roles to nodes as described in
  42. <<data-tiers>>.
  43. +
  44. For example, include the `data_warm` node role in the `elasticsearch.yml` file
  45. of each node in the warm tier:
  46. +
  47. [source,yaml]
  48. ----
  49. node.roles: [ "data_warm" ]
  50. ----
  51. * A host with the {agent} installed and configured to send logs to your {es}
  52. cluster.
  53. [discrete]
  54. [[example-using-index-lifecycle-policy-view-ilm-policy]]
  55. ==== View the policy
  56. The {agent} uses data streams with an index pattern of `logs-*-*` to store log
  57. monitoring data. The built-in `logs` {ilm-init} policy automatically manages
  58. backing indices for these data streams.
  59. To view the `logs` policy in {kib}:
  60. . Open the menu and go to **Stack Management > Index Lifecycle Policies**.
  61. . Select the `logs` policy.
  62. The `logs` policy uses the recommended rollover defaults: start writing to a new
  63. index when the current write index reaches 50GB or becomes 30 days old.
  64. To view or change the rollover settings, click **Settings** for the hot phase.
  65. Then disable **Use recommended defaults** to display the rollover 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 **Settings**.
  75. +
  76. --
  77. [role="screenshot"]
  78. image::images/ilm/tutorial-ilm-modify-default-warm-phase-rollover.png[Add a warm phase with custom settings]
  79. .. Set *Move data into phase when* to *30 days*. This moves indices to the warm
  80. tier 30 days after rollover.
  81. .. Enable **Replicas** and change *Number of replicas* to *1*.
  82. .. Enable *Force merge* and set *Number of segments* to *1*.
  83. --
  84. . Activate the delete phase and set *Move data into phase when* to *90* days.
  85. This deletes indices 90 days after rollover.
  86. +
  87. [role="screenshot"]
  88. image::images/ilm/tutorial-ilm-delete-rollover.png[Add a delete phase]
  89. . Click **Save Policy**.