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

Adjust ECS dynamic templates to support subobjects: false #96712

Merged
merged 30 commits into from
Jun 18, 2023

Conversation

eyalkoren
Copy link
Contributor

We cannot yet set subobjects: false by default at the root level for logs data streams, unless we either modify all shippers to flatten all documents or we automatically flatten objects in Elasticsearch.
However, we can already adjust the ECS dynamic templates to support that, which is what this PR does.

In order to test it, I am using a flatten document.

As I wrote in the test- it is not useable at the moment because setting subobjects: false through custom mappings fails with this error:

        "type" : "illegal_argument_exception",
        "reason" : "updating component template [logs@custom] results in invalid composable template [logs] after templates are merged",
        "caused_by" : {
          "type" : "illegal_argument_exception",
          "reason" : "composable template [logs] template after composition with component templates [logs-mappings, logs-settings, logs@custom, ecs@dynamic_templates] is invalid",
          "caused_by" : {
            "type" : "illegal_argument_exception",
            "reason" : "invalid composite mappings for [logs]",
            "caused_by" : {
              "type" : "mapper_parsing_exception",
              "reason" : "Failed to parse mapping: Tried to add subobject [data_stream] to object [_doc] which does not support subobjects",
              "caused_by" : {
                "type" : "mapper_parsing_exception",
                "reason" : "Tried to add subobject [data_stream] to object [_doc] which does not support subobjects",

@jbaiera if you find out why and how to avoid that- please let me know and I'll adjust what's needed.

In the mean time, this test can be executed by adding subobjects: false to logs-mappings.

@P1llus could you run your exhaustive ECS test with these dynamic templates to see that they are still valid for non-flatted as well?

eyalkoren added 26 commits May 16, 2023 17:34
@eyalkoren eyalkoren self-assigned this Jun 8, 2023
@elasticsearchmachine elasticsearchmachine added the external-contributor Pull request authored by a developer outside the Elasticsearch team label Jun 8, 2023
@elasticsearchmachine
Copy link
Collaborator

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

@eyalkoren
Copy link
Contributor Author

Worked around the issue described in #96712 (comment) by creating a dedicated template for the test, so this should be ready for review.
Thanks @felixbarny for the advice 🙏 ❤️

@eyalkoren eyalkoren marked this pull request as ready for review June 12, 2023 09:46
@elasticsearchmachine elasticsearchmachine added the Team:Data Management Meta label for data/management team label Jun 12, 2023
@elasticsearchmachine
Copy link
Collaborator

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

@eyalkoren eyalkoren requested a review from P1llus June 12, 2023 09:46
@felixbarny
Copy link
Member

The error you encountered sounds like a bug in how subobjects: false is handled. Please file a bug report for that.

@eyalkoren
Copy link
Contributor Author

The error you encountered sounds like a bug in how subobjects: false is handled. Please file a bug report for that.

Opened #96768

Copy link
Member

@jbaiera jbaiera left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@ruflin ruflin left a comment

Choose a reason for hiding this comment

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

LGTM

I find it slightly surprising that when we would use subobject: false that slightly different templates are required. This is ok for our template as we know the details but what about users. Is there a plan to make templates identical no matter if subobject is used or not?

@eyalkoren
Copy link
Contributor Author

I find it slightly surprising that when we would use subobject: false that slightly different templates are required. This is ok for our template as we know the details but what about users.

It was somewhat expected that we'd need to adjust, given the way that dynamic templates' match and path_match work.

Is there a plan to make templates identical no matter if subobject is used or not?

There is already only one set of dynamic ECS templates that support both- note that the new 250_logs_no_subobjects.yml test and the former 240_logs_ecs_mappings.yml tests all pass with the same mappings.

One of the things I discussed today with @P1llus is extending his test tool to create a flatten version of all ECS mappings in addition to the nested one it currently creates, thus enabling us test our mappings with subobjects: false even before we make it the default.

@eyalkoren
Copy link
Contributor Author

I modified @P1llus's test to use the final form of the ECS dynamic templates as we eventually merged them and ran it with the adjusted ECS mappings of this PR to verify that we don't have regression in this regard. Results seem consistent with the adjusted version:

Tested 1584/1581 Fields
Matched fields: 1581
Ignored fields: 3
Missmatched fields: 0

@eyalkoren
Copy link
Contributor Author

eyalkoren commented Jun 18, 2023

With my latest addition to the test, I was able to verify that when generating a document that contains the entire ECS fields in a flattened form, the mappings proposed in this PR work as expected with subobjects: false.
Therefore, I feel it's safe enough to merge at this point.
@P1llus if you get a chance to take another 👀 , even after merging, that would be great.

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 >enhancement external-contributor Pull request authored by a developer outside the Elasticsearch team Team:Data Management Meta label for data/management team v8.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants