index.asciidoc 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. [role="xpack"]
  2. [[data-stream-lifecycle]]
  3. == Data stream lifecycle
  4. A data stream lifecycle is the built-in mechanism data streams use to manage their lifecycle. It enables you to easily
  5. automate the management of your data streams according to your retention requirements. For example, you could configure
  6. the lifecycle to:
  7. * Ensure that data indexed in the data stream will be kept at least for the retention time you defined.
  8. * Ensure that data older than the retention period will be deleted automatically by {es} at a later time.
  9. To achieve that, it supports:
  10. * Automatic <<index-rollover,rollover>>, which chunks your incoming data in smaller pieces to facilitate better performance
  11. and backwards incompatible mapping changes.
  12. * Configurable retention, which allows you to configure the time period for which your data is guaranteed to be stored.
  13. {es} is allowed at a later time to delete data older than this time period.
  14. [discrete]
  15. [[data-streams-lifecycle-how-it-works]]
  16. === How does it work?
  17. In intervals configured by <<data-streams-lifecycle-poll-interval,`data_streams.lifecycle.poll_interval`>>, {es} goes over
  18. each data stream and performs the following steps:
  19. 1. Checks if the data stream has a data stream lifecycle configured, skipping any indices not part of a managed data stream.
  20. 2. Rolls over the write index of the data stream, if it fulfills the conditions defined by
  21. <<cluster-lifecycle-default-rollover,`cluster.lifecycle.default.rollover`>>.
  22. 3. Applies retention to the remaining backing indices. This means deleting the backing indices whose
  23. `generation_time` is longer than the configured retention period. The `generation_time` is only applicable to rolled over backing
  24. indices and it is either the time since the backing index got rolled over, or the time optionally configured in the
  25. <<index-data-stream-lifecycle-origination-date,`index.lifecycle.origination_date`>> setting.
  26. IMPORTANT: We use the `generation_time` instead of the creation time because this ensures that all data in the backing
  27. index have passed the retention period. As a result, the retention period is not the exact time data gets deleted, but
  28. the minimum time data will be stored.
  29. NOTE: The steps `2` and `3` apply only to backing indices that are not already managed by {ilm-init}, meaning that these indices either do
  30. not have an {ilm-init} policy defined, or if they do, they have <<index-lifecycle-prefer-ilm,`index.lifecycle.prefer_ilm`>>
  31. set to `false`.
  32. [discrete]
  33. [[data-stream-lifecycle-configuration]]
  34. === Configuring data stream lifecycle
  35. Since the lifecycle is configured on the data stream level, the process to configure a lifecycle on a new data stream and
  36. on an existing one differ.
  37. In the following sections, we will go through the following tutorials:
  38. * To create a new data stream with a lifecycle, you need to add the data stream lifecycle as part of the index template
  39. that matches the name of your data stream (see <<tutorial-manage-new-data-stream>>). When a write operation
  40. with the name of your data stream reaches {es} then the data stream will be created with the respective data stream lifecycle.
  41. * To update the lifecycle of an existing data stream you need to use the <<data-stream-lifecycle-api, data stream lifecycle APIs>>
  42. to edit the lifecycle on the data stream itself (see <<tutorial-manage-existing-data-stream>>).
  43. NOTE: Updating the data stream lifecycle of an existing data stream is different from updating the settings or the mapping,
  44. because it is applied on the data stream level and not on the individual backing indices.
  45. include::tutorial-manage-new-data-stream.asciidoc[]
  46. include::tutorial-manage-existing-data-stream.asciidoc[]