123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- [[data-streams-put-lifecycle]]
- === Set the lifecycle of a data stream
- ++++
- <titleabbrev>Put Data Stream Lifecycle</titleabbrev>
- ++++
- Configures the data stream lifecycle for the targeted data streams.
- [[put-lifecycle-api-prereqs]]
- ==== {api-prereq-title}
- If the {es} {security-features} are enabled, you must have the `manage_data_stream_lifecycle` index privilege or higher to use this API.
- For more information, see <<security-privileges>>.
- [[data-streams-put-lifecycle-request]]
- ==== {api-request-title}
- `PUT _data_stream/<data-stream>/_lifecycle`
- [[data-streams-put-lifecycle-desc]]
- ==== {api-description-title}
- Configures the data stream lifecycle for the targeted data streams. If multiple data streams are provided but at least one of them
- does not exist, then the update of the lifecycle will fail for all of them and the API will respond with `404`.
- [[data-streams-put-lifecycle-path-params]]
- ==== {api-path-parms-title}
- `<data-stream>`::
- (Required, string) Comma-separated list of data streams used to limit the request. Supports wildcards (`*`).
- To target all data streams use `*` or `_all`.
- [role="child_attributes"]
- [[put-data-lifecycle-api-query-parms]]
- ==== {api-query-parms-title}
- include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=ds-expand-wildcards]
- +
- Defaults to `open`.
- [[put-lifecycle-api-request-body]]
- ==== {api-request-body-title}
- `lifecycle`::
- (Required, object)
- +
- .Properties of `lifecycle`
- [%collapsible%open]
- ====
- `data_retention`::
- (Optional, string)
- If defined, every document added to this data stream will be stored at least for this time frame. Any time after this
- duration the document could be deleted. When empty, every document in this data stream will be stored indefinitely.
- ====
- [[data-streams-put-lifecycle-example]]
- ==== {api-examples-title}
- The following example sets the lifecycle of `my-data-stream`:
- [source,console]
- --------------------------------------------------
- PUT _data_stream/my-data-stream/_lifecycle
- {
- "data_retention": "7d"
- }
- --------------------------------------------------
- // TEST[setup:my_data_stream]
- // TEST[teardown:data_stream_cleanup]
- When the lifecycle is successfully updated in all data streams, you receive the following result:
- [source,console-result]
- --------------------------------------------------
- {
- "acknowledged": true
- }
- --------------------------------------------------
|