123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- [[data-streams-get-lifecycle]]
- === Get the lifecycle of a data stream
- ++++
- <titleabbrev>Get Data Stream Lifecycle</titleabbrev>
- ++++
- 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-repo-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"
- }
- },
- {
- "name": "my-data-stream-2",
- "lifecycle": {
- "enabled": true,
- "data_retention": "7d"
- }
- }
- ]
- }
- --------------------------------------------------
|