Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GET data stream API returns additional information #59128

Merged
merged 10 commits into from
Jul 7, 2020

Conversation

andreidan
Copy link
Contributor

@andreidan andreidan commented Jul 7, 2020

This adds the data stream's index template, the configured ILM policy
(if any) and the health status of the data stream to the GET _data_stream
response.

Relates to #58316
Relates to #53100

The proposed response looks like this:

{
  "data_streams" : [
    {
      "name" : "timeseries",
      "timestamp_field" : {
        "name" : "@timestamp",
        "mapping" : {
          "type" : "date"
        }
      },
      "indices" : [
        {
          "index_name" : ".ds-timeseries-000001",
          "index_uuid" : "m3Id6-T7TuOBuC3qoltdqQ"
        }
      ],
      "generation" : 1,
      "status" : "YELLOW",
      "template" : "timeseries_template",
      "ilm_policy" : "timeseries_policy"
    },
    {
      "name" : "timeseries_3",
      "timestamp_field" : {
        "name" : "@timestamp",
        "mapping" : {
          "type" : "date"
        }
      },
      "indices" : [
        {
          "index_name" : ".ds-timeseries_3-000001",
          "index_uuid" : "YJKrb9_yR2iukhi0vCy1zQ"
        }
      ],
      "generation" : 1,
      "status" : "GREEN",
      "template" : "timeseries_template",
      "ilm_policy" : "timeseries_policy"
    }
  ]
}

This adds the data stream's index template, the configured ILM policy
(if any) and the health status of the data stream to the GET _data_stream
response.
@andreidan andreidan added v8.0.0 :Data Management/Data streams Data streams and their lifecycles Team:Deployment Management Meta label for Management Experience - Deployment Management team v7.9.0 labels Jul 7, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features (:Core/Features/Data streams)

@elasticmachine elasticmachine added the Team:Data Management Meta label for data/management team label Jul 7, 2020
@andreidan andreidan requested a review from martijnvg July 7, 2020 09:51
@andreidan
Copy link
Contributor Author

@elasticmachine update branch

@andreidan andreidan removed the request for review from martijnvg July 7, 2020 11:14
@andreidan andreidan added the WIP label Jul 7, 2020
@andreidan
Copy link
Contributor Author

Added WIP as the HLRC still needs some work

Copy link
Contributor

@danhermann danhermann left a comment

Choose a reason for hiding this comment

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

I left one comment about REST tests that I think should be addressed. LGTM, otherwise.

Edit: Just saw you marked it WIP. I'll take another look at it when you've completed it.

Comment on lines 52 to 61
- match: { data_streams.0.name: simple-data-stream1 }
- match: { data_streams.0.timestamp_field.name: '@timestamp' }
- match: { data_streams.0.generation: 1 }
- length: { data_streams.0.indices: 1 }
- match: { data_streams.0.indices.0.index_name: '.ds-simple-data-stream1-000001' }
- match: { data_streams.1.name: simple-data-stream2 }
- match: { data_streams.1.timestamp_field.name: '@timestamp2' }
- match: { data_streams.0.generation: 1 }
- length: { data_streams.1.indices: 1 }
- match: { data_streams.1.indices.0.index_name: '.ds-simple-data-stream2-000001' }
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that at least one of these REST tests should be updated with the full list of fields that are returned from the get data stream API.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Dan, pushed a match for status and template (the lifecycle policy is tested in TimeseriesDataStreamIT as it's an xpack setting)

@andreidan andreidan removed the WIP label Jul 7, 2020
@andreidan andreidan requested a review from danhermann July 7, 2020 13:30
Copy link
Contributor

@danhermann danhermann left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks, @andreidan!

andreidan added 2 commits July 7, 2020 15:15
Restoring a data stream from a snapshot could install a data stream that
doesn't match any composable templates. This makes the index template field
in the `GET _data_stream` response optional.
@andreidan andreidan merged commit 0d9c98a into elastic:master Jul 7, 2020
andreidan added a commit to andreidan/elasticsearch that referenced this pull request Jul 7, 2020
This adds the data stream's index template, the configured ILM policy
(if any) and the health status of the data stream to the GET _data_stream
response.

Restoring a data stream from a snapshot could install a data stream that
doesn't match any composable templates. This also makes the `template`
field in the `GET _data_stream` response optional.

(cherry picked from commit 0d9c98a)
Signed-off-by: Andrei Dan <[email protected]>
@@ -119,11 +214,13 @@ public void writeTo(StreamOutput out) throws IOException {

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startArray();
for (DataStream dataStream : dataStreams) {
builder.startObject();
Copy link
Member

Choose a reason for hiding this comment

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

why was this top level data_streams field introduced? I don't think that this is needed?

Copy link
Contributor

Choose a reason for hiding this comment

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

It did make it easier to verify in REST tests that the number of returned data streams was as expected with a - length: { data_streams: 0 } directive. I don't think the length directive otherwise provides a way to refer to the root level of a response.

Copy link
Member

Choose a reason for hiding this comment

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

I think the - length: directive should be improved to handle this? Now the response format is changed, because a test directive can't handle something.

I also don't see length directive being used on the data_streams object, so maybe just keep using:

- match: { $body: [] }

?

Copy link
Contributor

Choose a reason for hiding this comment

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

Those are fair points. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Went of the top array field to be consistent with component and composable templates eg.

andreidan added a commit that referenced this pull request Jul 7, 2020
…9177)

* GET data stream API returns additional information (#59128)

This adds the data stream's index template, the configured ILM policy
(if any) and the health status of the data stream to the GET _data_stream
response.

Restoring a data stream from a snapshot could install a data stream that
doesn't match any composable templates. This also makes the `template`
field in the `GET _data_stream` response optional.

(cherry picked from commit 0d9c98a)
Signed-off-by: Andrei Dan <[email protected]>
jrodewig added a commit that referenced this pull request Jul 8, 2020
Updates docs and snippets for changes made to the get data stream API with
PR #59128.
jrodewig added a commit that referenced this pull request Jul 8, 2020
Updates docs and snippets for changes made to the get data stream API with
PR #59128.
jrodewig added a commit that referenced this pull request Jul 8, 2020
Updates docs and snippets for changes made to the get data stream API with
PR #59128.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Data Management/Data streams Data streams and their lifecycles Team:Data Management Meta label for data/management team Team:Deployment Management Meta label for Management Experience - Deployment Management team v7.9.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants