-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Fleet] Create intermediate objects when using dynamic mappings #169981
Merged
jsoriano
merged 13 commits into
elastic:main
from
jsoriano:fleet-create-object-dynamic-mappings
Nov 6, 2023
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
90fa641
Generate static mapping for parent object
jsoriano 20aa7da
It works for normal fields
jsoriano 45aee09
Refactor methods to add dynamic mappings
jsoriano cf2751e
Create intermediary dynamic mappings
jsoriano 47bc372
Inherit hasDynamicTemplateMappings
jsoriano f44e7bd
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine 8d9f0ce
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine 03d050a
Fix intermediate objects for objects without object_type
jsoriano 72eb732
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine 3f55ee2
Merge remote-tracking branch 'origin/main' into fleet-create-object-d…
jsoriano 69d9458
Merge remote-tracking branch 'jsoriano/fleet-create-object-dynamic-ma…
jsoriano b97f49d
Merge branch 'main' into fleet-create-object-dynamic-mappings
jsoriano 27e9ae1
Merge branch 'main' into fleet-create-object-dynamic-mappings
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
86 changes: 57 additions & 29 deletions
86
...gins/fleet/server/services/epm/elasticsearch/template/__snapshots__/template.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1151,7 +1151,12 @@ describe('EPM template', () => { | |
runtime: true | ||
`; | ||
const runtimeFieldMapping = { | ||
properties: {}, | ||
properties: { | ||
labels: { | ||
type: 'object', | ||
dynamic: true, | ||
}, | ||
}, | ||
dynamic_templates: [ | ||
{ | ||
'labels.*': { | ||
|
@@ -1177,7 +1182,12 @@ describe('EPM template', () => { | |
object_type: scaled_float | ||
`; | ||
const runtimeFieldMapping = { | ||
properties: {}, | ||
properties: { | ||
numeric_labels: { | ||
type: 'object', | ||
dynamic: true, | ||
}, | ||
}, | ||
dynamic_templates: [ | ||
{ | ||
numeric_labels: { | ||
|
@@ -1205,7 +1215,12 @@ describe('EPM template', () => { | |
default_metric: "max" | ||
`; | ||
const runtimeFieldMapping = { | ||
properties: {}, | ||
properties: { | ||
aggregate: { | ||
type: 'object', | ||
dynamic: true, | ||
}, | ||
}, | ||
dynamic_templates: [ | ||
{ | ||
'aggregate.*': { | ||
|
@@ -1226,7 +1241,7 @@ describe('EPM template', () => { | |
expect(mappings).toEqual(runtimeFieldMapping); | ||
}); | ||
|
||
it('tests processing groub sub fields in a dynamic template', () => { | ||
it('tests processing group sub fields in a dynamic template', () => { | ||
const textWithRuntimeFieldsLiteralYml = ` | ||
- name: group.*.network | ||
type: group | ||
|
@@ -1236,7 +1251,12 @@ describe('EPM template', () => { | |
metric_type: counter | ||
`; | ||
const runtimeFieldMapping = { | ||
properties: {}, | ||
properties: { | ||
group: { | ||
type: 'object', | ||
dynamic: true, | ||
}, | ||
}, | ||
dynamic_templates: [ | ||
{ | ||
'group.*.network.bytes': { | ||
|
@@ -1248,6 +1268,26 @@ describe('EPM template', () => { | |
}, | ||
}, | ||
}, | ||
{ | ||
'group.*.network': { | ||
path_match: 'group.*.network', | ||
match_mapping_type: 'object', | ||
mapping: { | ||
type: 'object', | ||
dynamic: true, | ||
}, | ||
}, | ||
}, | ||
{ | ||
'group.*': { | ||
path_match: 'group.*', | ||
match_mapping_type: 'object', | ||
mapping: { | ||
type: 'object', | ||
dynamic: true, | ||
}, | ||
}, | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Example of intermediary objects created using dynamic mappings, as they contain dynamic parts. |
||
], | ||
}; | ||
const fields: Field[] = safeLoad(textWithRuntimeFieldsLiteralYml); | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Example of intermediary object that is created as static property for dynamic templates.