mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 23:27:25 -04:00
* Remove `es-test-dir` book-scoped variable * Remove `plugins-examples-dir` book-scoped variable * Remove `:dependencies-dir:` and `:xes-repo-dir:` book-scoped variables - In `index.asciidoc`, two variables (`:dependencies-dir:` and `:xes-repo-dir:`) were removed. - In `sql/index.asciidoc`, the `:sql-tests:` path was updated to fuller path - In `esql/index.asciidoc`, the `:esql-tests:` path was updated idem * Replace `es-repo-dir` with `es-ref-dir` * Move `:include-xpack: true` to few files that use it, remove from index.asciidoc
149 lines
4.1 KiB
Text
149 lines
4.1 KiB
Text
[[data-streams-get-lifecycle]]
|
|
=== Get the lifecycle of a data stream
|
|
++++
|
|
<titleabbrev>Get Data Stream Lifecycle</titleabbrev>
|
|
++++
|
|
|
|
preview::[]
|
|
|
|
Gets the lifecycle of a set of data streams.
|
|
|
|
[[get-lifecycle-api-prereqs]]
|
|
==== {api-prereq-title}
|
|
|
|
* If the {es} {security-features} are enabled, you must have at least one of the `manage`
|
|
<<privileges-list-indices,index privilege>>, the `manage_data_stream_lifecycle` index privilege, or the
|
|
`view_index_metadata` privilege to use this API. For more information, see <<security-privileges>>.
|
|
|
|
[[data-streams-get-lifecycle-request]]
|
|
==== {api-request-title}
|
|
|
|
`GET _data_stream/<data-stream>/_lifecycle`
|
|
|
|
[[data-streams-get-lifecycle-desc]]
|
|
==== {api-description-title}
|
|
|
|
Gets the lifecycle of the specified data streams. If multiple data streams are requested but at least one of them
|
|
does not exist, then the API will respond with `404` since at least one of the requested resources could not be retrieved.
|
|
If the requested data streams do not have a lifecycle configured they will still be included in the API response but the
|
|
`lifecycle` key will be missing.
|
|
|
|
[[data-streams-get-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"]
|
|
[[get-data-lifecycle-api-query-parms]]
|
|
==== {api-query-parms-title}
|
|
|
|
include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=ds-expand-wildcards]
|
|
+
|
|
Defaults to `open`.
|
|
|
|
`include_defaults`::
|
|
(Optional, Boolean) If `true`, return all default settings in the response.
|
|
Defaults to `false`.
|
|
|
|
[role="child_attributes"]
|
|
[[get-lifecycle-api-response-body]]
|
|
==== {api-response-body-title}
|
|
|
|
`data_streams`::
|
|
(array of objects)
|
|
Contains information about retrieved data stream lifecycles.
|
|
+
|
|
.Properties of objects in `data_streams`
|
|
[%collapsible%open]
|
|
====
|
|
`name`::
|
|
(string)
|
|
Name of the data stream.
|
|
`lifecycle`::
|
|
(Optional, 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 undefined, every document in this data stream will be stored indefinitely.
|
|
|
|
`rollover`::
|
|
(Optional, object)
|
|
The conditions which will trigger the rollover of a backing index as configured by the cluster setting
|
|
`cluster.lifecycle.default.rollover`. This property is an implementation detail and it will only be retrieved
|
|
when the query param `include_defaults` is set to `true`. The contents of this field are subject to change.
|
|
=====
|
|
====
|
|
|
|
[[data-streams-get-lifecycle-example]]
|
|
==== {api-examples-title}
|
|
|
|
////
|
|
|
|
[source,console]
|
|
--------------------------------------------------
|
|
PUT /_index_template/my-template
|
|
{
|
|
"index_patterns" : ["my-data-stream*"],
|
|
"priority" : 1,
|
|
"data_stream": {},
|
|
"template": {
|
|
"lifecycle" : {
|
|
"data_retention" : "7d"
|
|
}
|
|
}
|
|
}
|
|
|
|
PUT /_data_stream/my-data-stream-1
|
|
PUT /_data_stream/my-data-stream-2
|
|
--------------------------------------------------
|
|
// TESTSETUP
|
|
|
|
[source,console]
|
|
--------------------------------------------------
|
|
DELETE _data_stream/my-data-stream*
|
|
DELETE _index_template/my-template
|
|
--------------------------------------------------
|
|
// TEARDOWN
|
|
|
|
////
|
|
|
|
Let's retrieve the lifecycles:
|
|
|
|
[source,console]
|
|
--------------------------------------------------
|
|
GET _data_stream/my-data-stream*/_lifecycle
|
|
--------------------------------------------------
|
|
|
|
The response will look like the following:
|
|
|
|
[source,console-result]
|
|
--------------------------------------------------
|
|
{
|
|
"data_streams": [
|
|
{
|
|
"name": "my-data-stream-1",
|
|
"lifecycle": {
|
|
"enabled": true,
|
|
"data_retention": "7d",
|
|
"effective_retention": "7d",
|
|
"retention_determined_by": "data_stream_configuration"
|
|
}
|
|
},
|
|
{
|
|
"name": "my-data-stream-2",
|
|
"lifecycle": {
|
|
"enabled": true,
|
|
"data_retention": "7d",
|
|
"effective_retention": "7d",
|
|
"retention_determined_by": "data_stream_configuration"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
--------------------------------------------------
|