Skip to content

Conversation

@flash1293
Copy link
Contributor

@flash1293 flash1293 commented Mar 22, 2024

Closes #1276

This PR adds a check whether any indexed docs have an _ignored field - this would indicate a mapping problem:

Example output:

Error: error running package system tests: could not complete test run: found _ignored fields in data stream logs-cel.cel-ep

How to test

Cause a mapping error by configuring a field in a wrong way - I used the cel package:

--- a/packages/cel/fields/input.yml +++ b/packages/cel/fields/input.yml @@ -3,7 +3,8 @@ - name: message - external: ecs + type: keyword + ignore_above: 5 - name: input.name type: constant_keyword - name: input.type

As message is longer than 5 characters, this will cause message to not be mapping correctly. Running the system tests for cel will fail with the error shown above.

Notes

The check is done via aggregations instead of checking through each documents to be able to validate all docs, not just the ones that are fetched (which are capped at 500). Once elastic/elasticsearch#101373 is merged, we can use a terms query here for better debug information (but it's also possible to check the index manually to find the root cause).

This cannot be meaningfully applied to the pipeline tests currently, as they don't take mappings into account (elastic/elasticsearch#99920).

@flash1293
Copy link
Contributor Author

flash1293 commented Mar 22, 2024

It actually looks like this check finds an error right away:

Error: error running package system tests: could not complete test run: found _ignored fields in data stream logs-auditd_manager.auditd-ep

 
I ran this test locally and the issue is the event.original field, which is mapped as a keyword with ignore_above of 1024 - I think it will be resolved by #1733 , can you confirm @jsoriano ?

@flash1293 flash1293 requested a review from jsoriano March 22, 2024 10:21
@ruflin
Copy link
Contributor

ruflin commented Mar 22, 2024

++, nice addition. The more we add of these checks, the higher the quality of integrations will be.

@jsoriano
Copy link
Member

test integrations

@jsoriano
Copy link
Member

I ran this test locally and the issue is the event.original field, which is mapped as a keyword with ignore_above of 1024 - I think it will be resolved by #1733 , can you confirm @jsoriano ?

It is possible, but we would need to test it when ready.

Copy link
Member

@jsoriano jsoriano 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!

But let's wait to see if it would affect many existing integrations. If it does, we could introduce this only for packages using the next version of the spec.

@elasticmachine
Copy link
Collaborator

Created or updated PR in integrations repository to test this version. Check elastic/integrations#9439

@flash1293
Copy link
Contributor Author

test integrations

@elasticmachine
Copy link
Collaborator

Created or updated PR in integrations repository to test this version. Check elastic/integrations#9439

@flash1293
Copy link
Contributor Author

test integrations

@flash1293
Copy link
Contributor Author

Still the same error in the test package, I will look into this

@elasticmachine
Copy link
Collaborator

Created or updated PR in integrations repository to test this version. Check elastic/integrations#9439


allFieldsBody = `{"fields": ["*"]}`
DevDeployDir = "_dev/deploy"
checkFieldsBody = `{"fields": ["*"], "aggs": {"degraded": {"filter": {"exists": {"field": "_ignored"}}}}}`
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 returned error should at a minimum include the names of ignored fields. You could aggregate those field names. (It needs a runtime field to access the names as per elastic/elasticsearch#59946 (comment)).

POST logs-*/_search { "size": 10, "runtime_mappings": { "my_ignored": { "type": "keyword", "script": { "source": "for (def v : params['_fields']._ignored.values) { emit(v); }" } } }, "aggs": { "all_ignored": { "filter": { "exists": { "field": "_ignored" } }, "aggs": { "ignore_fields": { "terms": { "size": 100, "field": "my_ignored" } } } } } } 
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As mentioned I wanted to wait with this until the change to make _ignored aggregatable is merged, but you are right that we don't need to block on it - I changed the code to use the runtime field workaround for now.

@flash1293
Copy link
Contributor Author

test integrations

@flash1293
Copy link
Contributor Author

The test auditd_manager package still fails as it relies on the ecs@mappings component template which won't be fixed until elastic/elasticsearch#106714 is released - we can silence the test by explicitly mapping event.original correctly, but let's check how many of the real integrations are affected in a similar way - if there are a lot, we either should:

  • wait for 8.14.0 until we merge this
  • or make an exception for event.original for now to at least detect other mapping errors
@elasticmachine
Copy link
Collaborator

Created or updated PR in integrations repository to test this version. Check elastic/integrations#9439

@flash1293
Copy link
Contributor Author

test integrations

@elasticmachine
Copy link
Collaborator

Created or updated PR in integrations repository to test this version. Check elastic/integrations#9439

@flash1293
Copy link
Contributor Author

@jsoriano As the need came up in the existing failures, I opened a PR on the package-spec to add a flag to add exceptions to this test: elastic/package-spec#743

Once this is merged, I'm going to update this PR to check this definition and skip the check if it makes sense. Once this is in place, it should be possible to mute existing errors in the integrations repo and merge this PR.

@ShourieG
Copy link

ShourieG commented May 7, 2024

@flash1293, I've often seen encoded payload field values exceed 6-7k characters easily. This can easily go up even more in real world scenarios and the issue is these are always clumped into 'keyword' types. We really need a way to mark 'keyword' types to have an attribute like 'ignore_length: true' or some sort or introduce a new type for storing encoded payloads, otherwise in a real scenario these fields will not get indexed after the recent changes and just addressing the test scenarios won't work.

@flash1293
Copy link
Contributor Author

@ShourieG Two questions:

  • You mean this becoming an Elasticsearch feature so it's always considered, not just during package development?
  • Why are these fields indexed as keyword? Wouldn't it make sense to not index them in the first place if they are usually ignored anyway? This would mean that short values also wouldn't get indexed anymore, but the use of such a field seems questionable anyway - if it's only searchable in 50% of cases, will that actually help during exploration?
@flash1293
Copy link
Contributor Author

otherwise in a real scenario these fields will not get indexed after the recent changes and just addressing the test scenarios won't work

The changes around _ignored didn't change when values got indexed or not, it's just about exposing the problem.

@ShourieG
Copy link

ShourieG commented May 7, 2024

otherwise in a real scenario these fields will not get indexed after the recent changes and just addressing the test scenarios won't work

The changes around _ignored didn't change when values got indexed or not, it's just about exposing the problem.

@flash1293, Ah alright, I guess I misunderstood initially the issue around indexing. Then maybe adding the 'ignore_length: true' to the package spec so we can specify that during the tests would be pretty awesome? Something that we can specify in the validation.yml ?

@flash1293
Copy link
Contributor Author

@ShourieG Currently working on it here: elastic/package-spec#743

@flash1293
Copy link
Contributor Author

Muting existing failures here: elastic/integrations#9823

Copy link
Member

@jsoriano jsoriano 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 for the work here! Feel free to merge the change in the spec too.

@flash1293
Copy link
Contributor Author

/ci

@flash1293
Copy link
Contributor Author

@jsoriano it seems like the build failed, how can I trigger it again? It doesn't look related to the changes of the PR

@jsoriano
Copy link
Member

jsoriano commented May 9, 2024

@jsoriano it seems like the build failed, how can I trigger it again? It doesn't look related to the changes of the PR

You can write a /test comment to re-launch everything, or use the buildkite UI to retry single stages:
image

The failure happening now is in a package whose tests use to be flaky, so probably the failure is not related.

@flash1293
Copy link
Contributor Author

/test

@flash1293
Copy link
Contributor Author

/test

1 similar comment
@flash1293
Copy link
Contributor Author

/test

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

10 participants