Skip to content

Conversation

gmarouli
Copy link
Contributor

In this PR we expose the global retention via the GET _data_stream/{target}/_lifecycle API.

Since the global retention is a main feature of the data stream lifecycle we chose to expose it by default.

GET /_data_stream/my-data-stream/_lifecycle
{
 "global_retention": {
      "default_retention": "7d",
      "max_retention": "365d"
  }, 
  "data_streams": [...]
}

@gmarouli gmarouli added >enhancement :Data Management/Data streams Data streams and their lifecycles labels Aug 26, 2024
Copy link
Contributor

Documentation preview:

@elasticsearchmachine
Copy link
Collaborator

Hi @gmarouli, I've created a changelog YAML for you.

@gmarouli
Copy link
Contributor Author

@elasticmachine update branch

@gmarouli
Copy link
Contributor Author

@elasticmachine update branch

@gmarouli gmarouli requested review from masseyke and dakrone August 27, 2024 12:12
@gmarouli
Copy link
Contributor Author

I will double check the docs failure if it happens again.

@gmarouli gmarouli marked this pull request as ready for review August 27, 2024 12:12
@elasticsearchmachine elasticsearchmachine added the Team:Data Management Meta label for data/management team label Aug 27, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

public Iterator<ToXContent> toXContentChunked(ToXContent.Params outerParams) {
return Iterators.concat(Iterators.single((builder, params) -> {
builder.startObject();
if (globalRetention != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not want to show empty global configuration if none is configured? I'm trying to think of something analogous in an API we have (to see if it does this, or shows empty) but haven't thought of anything yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have been going back and forth on this too. In the same when we have no data streams we show an empty list. "data_streams": []. But because this is an object and not a list, I wasn't sure how to approach it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think that having global_retention: {} is more descriptive? Like showing that, yes we do support it and it's non set?

Copy link
Contributor Author

@gmarouli gmarouli Aug 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the implementation to reflect this option.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also on the fence. I have no strong feeling either way. But maybe it's nice having it always present -- that way you know it's not set, rather than that you're just not looking for it in the right place.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe @dakrone has an opinion or knows of some relevant precedent.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One argument against this is that now we need to update every yaml rest test that returns a data stream to require the data_stream_global_retention, don't we? Otherwise backwards compatibility test runs will fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we do not have that many though. I will double check to ensure they are correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While checking on the global retention in the existing get lifecycle tests, I noticed..... they were not even running :(. I fixed that in 15fa8e1.

I also decided to merge the two files into one. It seems to me that since the global retention is part of the response it should be part of the basic tests.

@gmarouli gmarouli requested a review from masseyke August 28, 2024 15:32
Copy link
Member

@masseyke masseyke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, although it would be good to see what Lee thinks bout always including the global_retention piece in the response.

@gmarouli
Copy link
Contributor Author

@elasticmachine update branch

Copy link
Member

@dakrone dakrone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM also, I think having global_retention is fine

@gmarouli
Copy link
Contributor Author

gmarouli commented Sep 2, 2024

@elasticmachine update branch

@gmarouli gmarouli added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Sep 2, 2024
@elasticsearchmachine elasticsearchmachine merged commit 91f4023 into elastic:main Sep 2, 2024
17 checks passed
@gmarouli gmarouli deleted the expose-global-retention-settings-v2 branch September 2, 2024 08:40
cbuescher pushed a commit to cbuescher/elasticsearch that referenced this pull request Sep 4, 2024
…ic#112210)

In this PR we expose the global retention via the `GET
_data_stream/{target}/_lifecycle` API.

Since the global retention is a main feature of the data stream
lifecycle we chose to expose it by default.

```
GET /_data_stream/my-data-stream/_lifecycle
{
 "global_retention": {
      "default_retention": "7d",
      "max_retention": "365d"
  }, 
  "data_streams": [...]
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) :Data Management/Data streams Data streams and their lifecycles >enhancement Team:Data Management Meta label for data/management team test-update-serverless v8.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants