Set the lifecycle of a data streamedit
Configures the data stream lifecycle for the targeted data streams.
Prerequisitesedit
If the Elasticsearch 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.
Requestedit
PUT _data_stream/<data-stream>/_lifecycle
Descriptionedit
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
.
Path parametersedit
-
<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
.
Query parametersedit
-
expand_wildcards
-
(Optional, string) Type of data stream that wildcard patterns can match. Supports comma-separated values, such as
open,hidden
. Valid values are:-
all
,hidden
- Match any data stream, including hidden ones.
-
open
,closed
- Matches any non-hidden data stream. Data streams cannot be closed.
-
none
- Wildcard patterns are not accepted.
Defaults to
open
. -
Request bodyedit
-
lifecycle
-
(Required, object)
Properties of
lifecycle
-
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.
-
Examplesedit
The following example sets the lifecycle of my-data-stream
:
PUT _data_stream/my-data-stream/_lifecycle { "data_retention": "7d" }
When the lifecycle is successfully updated in all data streams, you receive the following result:
{ "acknowledged": true }