-
Notifications
You must be signed in to change notification settings - Fork 127
Use fields if synthetic mode is enabled #1283
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
Conversation
| if len(results.ComponentTemplates) == 0 { | ||
| logger.Debugf("no component template found for data stream %s", dataStream) | ||
| return false, nil | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In current elastic stack version, there is no component template for sql_input package (input) for the Elastic stack version started (8.6.2).
In that scenario, I assume that synthetic is not enabled.
|
/test |
|
The test package fails with these errors: Probably it needs to wait until elastic-package runs by default 8.7.1 version so the synthetic source mode is detected. |
Shall we update the stack version being used then? |
It is being done in this PR #1274 |
I guess we are good now :) |
There are still errors to be fixed in field validations when running static tests:
Trying to find a way to solve that yet. |
|
@mrodm can I also mark this as closing elastic/integrations#6099 ? |
@jlind23 Not sure if it could be considered closed. If the current approach is approved, some changes in that integration would be needed so its tests are successful:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job here, there are quite some tricky cases.
I wonder if we can make this code less dependant on synthetic mode being enabled or not. For example we could try to always merge the fields in the source and the fields in fields. And assume that we have to disable normalization validation for all fields coming from fields. Then maybe we wouldn't even need to check if synthetic is enabled. But we can revisit this later when supporting runtime fields.
Something I think we have to confirm in any case before merging this is the format of the sample event, objects used to be expanded, but they are not here for the synthetic mode.
test/packages/other/synthetic_mode/data_stream/synthetic/sample_event.json
Outdated
Show resolved
Hide resolved
| func (h hits) getDocs(syntheticsEnabled bool) []common.MapStr { | ||
| if syntheticsEnabled { | ||
| return h.Fields | ||
| } | ||
| return h.Source | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably fine for synthetics, but I wonder if we should actually merge fields and source, to support also the runtime fields cases. But we can think about this when supporting tests with runtime fields.
|
/test |
Expand objects when docs retrieved from Elasticsearch and synthetic mode is enabled. That would keep the same format of the sample_event.json when that file is generated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, the sample document looks better now, added a couple of suggestions more about it.
test/packages/other/synthetic_mode/data_stream/synthetic/sample_event.json
Outdated
Show resolved
Hide resolved
💚 Build Succeeded
History
cc @mrodm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
Closes #1253
This PR adds the support to check
fieldskey from the documents retrieved from the Elasticsearch instead of_source.For that, for each system test it is checked whether or not the
synthetic modeis enabled:In case that data stream (component template) has synthetic enabled, there are some changes required:
fieldsare arrays and this validation cannot be ensured.fieldsare arrays, and that's need to be taken into account when checking for exact valuessyntheticssource mode is enabled, this file is generated using thefieldskey from the documents with some modificationsA test package has been included to test the synthetic mode:
sample_event.jsonis written using thefieldskey from the documentAs part of this PR:
internal/fields/validate.go.Considerations
As synthetic source mode is enabled (as part of the time series),
_sourcefield gets built from the documents and the fields on the document could be differnt.For that, in case
syntheticsource mode is enabled, it is used thefieldskey from the documents retrieved from Elasticsearch instead of the_sourcefield.This makes that
sample_event.jsonfiles must be re-generated for those data streams.Packages (data streams) that do not use this mode are tested using the same
_sourcefield. No changes for them.How to test
For this it can be used the
apache_tomcatfrom the integrations repositoryapache_tomcatpackage foldercachedatastream to set thetime_seriesmode. Add at the end of the manifest this definition: