Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
ea4ef55
Introduce data stream global retention cluster state entry
gmarouli Feb 20, 2024
0c5e997
Add PUT/GET APIs
gmarouli Feb 20, 2024
ceb41cd
Add delete API
gmarouli Feb 21, 2024
6b6a884
Fixes
gmarouli Feb 21, 2024
e3ed372
Add permission test for delete action
gmarouli Feb 21, 2024
f068eb1
Remove featureService, at this point it's not adding anything
gmarouli Feb 21, 2024
ffe599b
Fix tests
gmarouli Feb 21, 2024
176a7fe
Adding tests for UpdateDataStreamGlobalRetentionService
gmarouli Feb 21, 2024
096db92
Fix format
gmarouli Feb 21, 2024
e769a5e
Merge branch 'main' into add-data-stream-global-retention-config
gmarouli Feb 21, 2024
fc715a7
Add tests for listener
gmarouli Feb 21, 2024
82e5df1
Test cluster state update
gmarouli Feb 22, 2024
f3a2b60
Fix imports
gmarouli Feb 22, 2024
9e865fe
Merge with main
gmarouli Mar 4, 2024
5823285
Fix test
gmarouli Mar 4, 2024
bcb6a35
Another test fix
gmarouli Mar 4, 2024
33aecea
Add references to pages
gmarouli Mar 4, 2024
121abf6
Merge branch 'main' into add-data-stream-global-retention-config
gmarouli Mar 4, 2024
d0775ed
merge with main
gmarouli Mar 5, 2024
9eb2866
Merge branch 'main' into add-data-stream-global-retention-config
gmarouli Mar 5, 2024
c545d5e
Fix test
gmarouli Mar 5, 2024
bf3f684
merge with main
gmarouli Mar 6, 2024
0663227
merge with main
gmarouli Mar 6, 2024
f6c79e1
merge with main
gmarouli Mar 7, 2024
f53c2cd
Reuse common params description
gmarouli Mar 7, 2024
4893339
Fix docs according to comments
gmarouli Mar 7, 2024
83a2275
Remove unit test covered by a combination other tests
gmarouli Mar 7, 2024
8782ce0
Remove unused getter
gmarouli Mar 7, 2024
d26483c
Merge with main
gmarouli Mar 8, 2024
58a6464
Merge with main
gmarouli Mar 11, 2024
0717e22
Merge with main
gmarouli Mar 20, 2024
50a69cd
Add node feature for global retention
gmarouli Mar 20, 2024
5e24149
merge with main
gmarouli Mar 20, 2024
e569043
Revert faulty condition
gmarouli Mar 20, 2024
01bcae5
Add validation
gmarouli Mar 20, 2024
89df270
Merge branch 'main' into add-data-stream-global-retention-config
gmarouli Mar 21, 2024
669aaa2
Enrich documentation
gmarouli Mar 21, 2024
eeeabeb
Fix doc test
gmarouli Mar 21, 2024
b4ff9d0
Revert failed response in the wrong place
gmarouli Mar 21, 2024
a5cbe34
Merge branch 'main' into add-data-stream-global-retention-config
elasticmachine Mar 22, 2024
48565ab
Update docs/changelog/105682.yaml
gmarouli Mar 22, 2024
3e392df
Add java rest test for global retention
gmarouli Mar 22, 2024
d8aa467
Update existing tests with effective retention
gmarouli Mar 22, 2024
08d7875
Fix bug and enhance tests
gmarouli Mar 22, 2024
8eb26f0
Bump versions of yaml testing with effective retention
gmarouli Mar 22, 2024
0f63703
Merge with main
gmarouli Mar 22, 2024
aae96e3
Use cluster_feature in yaml tests
gmarouli Mar 22, 2024
0ad6c6c
Merge branch 'main' into add-data-stream-global-retention-config
gmarouli Mar 26, 2024
4265c79
Test if the skip version works better
gmarouli Mar 26, 2024
c13a4b6
Update change log
gmarouli Mar 26, 2024
e90e686
Merge branch 'main' into add-data-stream-global-retention-config
gmarouli Mar 26, 2024
3e44a0e
Merge branch 'main' into add-data-stream-global-retention-config
gmarouli Mar 27, 2024
8959dc3
Fixing typos and grammar errors
gmarouli Mar 27, 2024
78a5af2
Fix tutorial format
gmarouli Mar 27, 2024
61b31e6
Update docs/changelog/105682.yaml
gmarouli Mar 27, 2024
7e87ed4
Merge branch 'main' into add-data-stream-global-retention-config
gmarouli Mar 28, 2024
fb25877
Update highlights
gmarouli Mar 28, 2024
8074f33
Rename project to cluster to be inline with the rest of the docs
gmarouli Mar 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/changelog/105682.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
pr: 105682
summary: Introduce global retention in data stream lifecycle.
area: Data streams
type: feature
issues:
- 106169
highlight:
title: Add global retention in data stream lifecycle
body: |-
Data stream lifecycle now supports configuring retention on a cluster level, namely global retention. Global retention
allows us to configure two different retentions:

- `default_retention` is applied to all data streams managed by the data stream lifecycle that do not have retention
defined on the data stream level.
- `max_retention` is applied to all data streams managed by the data stream lifecycle and it allows any data stream
data to be deleted after the `max_retention` has passed.

Furthermore, we introduce the term `effective_retention` which is the retention applied at a certain moment to a data
stream considering all the available retention configurations.
notable: true
14 changes: 13 additions & 1 deletion docs/reference/data-streams/data-stream-apis.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ preview:[]
preview:[]
* <<data-streams-explain-lifecycle,Explain data stream lifecycle>>
preview:[]
* <<data-streams-get-lifecycle-stats, Get data stream lifecycle stats>>
* <<data-streams-get-lifecycle-stats,Get data stream lifecycle stats>>
preview:[]
* <<data-streams-put-global-retention,Update the global retention for data stream lifecycle managed data streams>>
preview:[]
* <<data-streams-get-global-retention,Get the global retention for data stream lifecycle managed data streams>>
preview:[]
* <<data-streams-delete-global-retention,Delete the global retention for data stream lifecycle managed data streams>>
preview:[]

The following API is available for <<tsds,time series data streams>>:
Expand Down Expand Up @@ -59,4 +65,10 @@ include::{es-repo-dir}/data-streams/lifecycle/apis/explain-lifecycle.asciidoc[]

include::{es-repo-dir}/data-streams/lifecycle/apis/get-lifecycle-stats.asciidoc[]

include::{es-repo-dir}/data-streams/lifecycle/apis/put-global-retention.asciidoc[]

include::{es-repo-dir}/data-streams/lifecycle/apis/get-global-retention.asciidoc[]

include::{es-repo-dir}/data-streams/lifecycle/apis/delete-global-retention.asciidoc[]

include::{es-repo-dir}/indices/downsample-data-stream.asciidoc[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
[[data-streams-delete-global-retention]]
=== Delete the global retention of data streams
++++
<titleabbrev>Delete Data Stream Global Retention</titleabbrev>
++++

preview::[]

Deletes the global retention configuration that applies on every data stream managed by <<data-stream-lifecycle,data stream lifecycle>>.

[[delete-global-retention-api-prereqs]]
==== {api-prereq-title}

** If the {es} {security-features} are enabled, you must have the `manage_data_stream_global_retention` <<privileges-list-cluster,cluster privilege>> to use this API.

[[data-streams-delete-global-retention-request]]
==== {api-request-title}

`DELETE _data_stream/_global_retention`

[[data-streams-delete-global-retention-desc]]
==== {api-description-title}

Deletes the global retention configuration that is applied on data streams managed by data stream lifecycle.

[role="child_attributes"]
[[delete-global-retention-api-query-parms]]
==== {api-query-parms-title}

`dry_run`::
(Boolean) Signals that the request should determine the effect of the removal of the existing without updating
the global retention. The default value is `false`, which means the removal will happen.

[[delete-global-retention-api-response-body]]
==== {api-response-body-title}

`acknowledged`::
(boolean)
True, if the global retention has been removed. False, if it fails or if it was a dry run.

`dry_run`::
(boolean)
True, if this was a dry run, false otherwise.

`affected_data_streams`::
(array of objects)
Contains information about the data streams affected by the change.
+
.Properties of objects in `affected_data_streams`
[%collapsible%open]
====
`name`::
(string)
Name of the data stream.
`previous_effective_retention`::
(string)
The retention that was effective before the change of this request. `infinite` if there was no retention applicable.
`new_effective_retention`::
(string)
The retention that is or would be effective after this request. `infinite` if there is no retention applicable.
====

[[data-streams-delete-global-retention-example]]
==== {api-examples-title}

////

[source,console]
--------------------------------------------------
PUT _data_stream/_global_retention
{
"default_retention": "7d",
"max_retention": "90d"
}

PUT /_index_template/template
{
"index_patterns": ["my-data-stream*"],
"template": {
"lifecycle": {}
},
"data_stream": { }
}

PUT /_data_stream/my-data-stream
----
// TESTSETUP
////

////
[source,console]
----
DELETE /_data_stream/my-data-stream*
DELETE /_index_template/template
DELETE /_data_stream/_global_retention
----
// TEARDOWN
////

Let's update the global retention:
[source,console]
--------------------------------------------------
DELETE _data_stream/_global_retention
--------------------------------------------------

The response will look like the following:

[source,console-result]
--------------------------------------------------
{
"acknowledged": true,
"dry_run": false,
"affected_data_streams": [
{
"name": "my-data-stream",
"previous_effective_retention": "7d",
"new_effective_retention": "infinite"
}
]
}
--------------------------------------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
[[data-streams-get-global-retention]]
=== Get the global retention of data streams
++++
<titleabbrev>Get Data Stream Global Retention</titleabbrev>
++++

preview::[]

Gets the global retention that applies on every data stream managed by <<data-stream-lifecycle,data stream lifecycle>>.

[[get-global-retention-api-prereqs]]
==== {api-prereq-title}

** If the {es} {security-features} are enabled, you must have the `monitor_data_stream_global_retention` or
`manage_data_stream_global_retention` <<privileges-list-cluster,cluster privilege>> to use this API.

[[data-streams-get-global-retention-request]]
==== {api-request-title}

`GET _data_stream/_global_retention`

[[data-streams-get-global-retention-desc]]
==== {api-description-title}

Gets the global retention configuration that is applied on data streams managed by data stream lifecycle.

[role="child_attributes"]
[[get-global-retention-api-query-parms]]
==== {api-query-parms-title}

include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=local]

include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=master-timeout]

[[get-global-retention-api-response-body]]
==== {api-response-body-title}

`default_retention`::
(Optional, string)
The default retention that will apply to any data stream managed by data stream lifecycle that does not have a retention
defined on the data stream level.

`max_retention`::
(Optional, string)
The max retention that will apply to all data streams managed by data stream lifecycle. The max retention will override the
retention of a data stream whose retention exceeds the max retention.


[[data-streams-get-global-retention-example]]
==== {api-examples-title}

////

[source,console]
--------------------------------------------------
PUT _data_stream/_global_retention
{
"default_retention": "7d",
"max_retention": "90d"
}
--------------------------------------------------
// TESTSETUP

[source,console]
--------------------------------------------------
DELETE _data_stream/_global_retention
--------------------------------------------------
// TEARDOWN

////

Let's retrieve the global retention:

[source,console]
--------------------------------------------------
GET _data_stream/_global_retention
--------------------------------------------------

The response will look like the following:

[source,console-result]
--------------------------------------------------
{
"default_retention": "7d", <1>
"max_retention": "90d" <2>
}
--------------------------------------------------
<1> 7 days retention will be applied to any data stream that does not have retention set in its lifecycle.
<2> 90 days retention will be applied to all data streams that have retention that exceeds the 90 days, this
applies to data streams that have infinite retention too.
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
[[data-streams-put-global-retention]]
=== Update the global retention of data streams
++++
<titleabbrev>Update Data Stream Global Retention</titleabbrev>
++++

preview::[]

Updates the global retention configuration that applies on every data stream managed by <<data-stream-lifecycle,data stream lifecycle>>.

[[put-global-retention-api-prereqs]]
==== {api-prereq-title}

** If the {es} {security-features} are enabled, you must have the `manage_data_stream_global_retention` <<privileges-list-cluster,cluster privilege>> to use this API.

[[data-streams-put-global-retention-request]]
==== {api-request-title}

`PUT _data_stream/_global_retention`

[[data-streams-put-global-retention-desc]]
==== {api-description-title}

Updates the global retention configuration that is applied on data streams managed by data stream lifecycle.

[role="child_attributes"]
[[put-global-retention-api-query-parms]]
==== {api-query-parms-title}

`dry_run`::
(Boolean) Signals that the request should determine the effect of the provided configuration without updating the
global retention settings. The default value is `false`, which means the configuration provided will be applied.

[[put-global-retention-api-request-body]]
==== {api-request-body-title}

`default_retention`::
(Optional, string)
The default retention that will apply to any data stream managed by data stream lifecycle that does not have a retention
defined on the data stream level.

`max_retention`::
(Optional, string)
The max retention that will apply to all data streams managed by data stream lifecycle. The max retention will override the
retention of a data stream which retention exceeds the max retention.

[[put-global-retention-api-response-body]]
==== {api-response-body-title}

`acknowledged`::
(boolean)
True, if the global retention has been updated to the provided values. False, if it fails or if it was a dry run.

`dry_run`::
(boolean)
True, if this was a dry run, false otherwise.

`affected_data_streams`::
(array of objects)
Contains information about the data streams affected by the change.
+
.Properties of objects in `affected_data_streams`
[%collapsible%open]
====
`name`::
(string)
Name of the data stream.
`previous_effective_retention`::
(string)
The retention that was effective before the change of this request. `infinite` if there was no retention applicable.
`new_effective_retention`::
(string)
The retention that is or would be effective after this request. `infinite` if there is no retention applicable.
====

[[data-streams-put-global-retention-example]]
==== {api-examples-title}

////
[source,console]
----
PUT /_index_template/template
{
"index_patterns": ["my-data-stream*"],
"template": {
"lifecycle": {}
},
"data_stream": { }
}

PUT /_data_stream/my-data-stream
----
// TESTSETUP
////

////
[source,console]
----
DELETE /_data_stream/my-data-stream*
DELETE /_index_template/template
DELETE /_data_stream/_global_retention
----
// TEARDOWN
////

Let's update the global retention:
[source,console]
--------------------------------------------------
PUT _data_stream/_global_retention
{
"default_retention": "7d",
"max_retention": "90d"
}
--------------------------------------------------

The response will look like the following:

[source,console-result]
--------------------------------------------------
{
"acknowledged": true,
"dry_run": false,
"affected_data_streams": [
{
"name": "my-data-stream",
"previous_effective_retention": "infinite",
"new_effective_retention": "7d"
}
]
}
--------------------------------------------------
Loading