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

[Fleet] Create intermediate objects when using dynamic mappings #169981

Merged
merged 13 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,12 @@ describe('EPM template', () => {
runtime: true
`;
const runtimeFieldMapping = {
properties: {},
properties: {
labels: {
type: 'object',
dynamic: true,
},
Copy link
Member Author

@jsoriano jsoriano Oct 26, 2023

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.

},
dynamic_templates: [
{
'labels.*': {
Expand All @@ -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: {
Expand Down Expand Up @@ -1205,7 +1215,12 @@ describe('EPM template', () => {
default_metric: "max"
`;
const runtimeFieldMapping = {
properties: {},
properties: {
aggregate: {
type: 'object',
dynamic: true,
},
},
dynamic_templates: [
{
'aggregate.*': {
Expand All @@ -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
Expand All @@ -1236,7 +1251,12 @@ describe('EPM template', () => {
metric_type: counter
`;
const runtimeFieldMapping = {
properties: {},
properties: {
group: {
type: 'object',
dynamic: true,
},
},
dynamic_templates: [
{
'group.*.network.bytes': {
Expand All @@ -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,
},
},
},
Copy link
Member Author

Choose a reason for hiding this comment

The 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);
Expand Down
Loading
Loading