Skip to content

Commit 478e565

Browse files
committed
add body back
1 parent ad285c6 commit 478e565

2 files changed

Lines changed: 69 additions & 64 deletions

File tree

x-pack/platform/plugins/shared/alerting/server/alerts_service/lib/create_or_update_index_template.test.ts

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,43 +16,45 @@ const clusterClient = elasticsearchServiceMock.createClusterClient().asInternalU
1616

1717
const IndexTemplate = (namespace = 'default', useDataStream = false) => ({
1818
name: `.alerts-test.alerts-${namespace}-index-template`,
19-
_meta: {
20-
kibana: {
21-
version: '8.6.1',
19+
body: {
20+
_meta: {
21+
kibana: {
22+
version: '8.6.1',
23+
},
24+
managed: true,
25+
namespace,
2226
},
23-
managed: true,
24-
namespace,
25-
},
26-
composed_of: ['mappings1', 'framework-mappings'],
27-
index_patterns: [`.internal.alerts-test.alerts-${namespace}-*`],
28-
template: {
29-
mappings: {
30-
_meta: {
31-
kibana: {
32-
version: '8.6.1',
27+
composed_of: ['mappings1', 'framework-mappings'],
28+
index_patterns: [`.internal.alerts-test.alerts-${namespace}-*`],
29+
template: {
30+
mappings: {
31+
_meta: {
32+
kibana: {
33+
version: '8.6.1',
34+
},
35+
managed: true,
36+
namespace,
3337
},
34-
managed: true,
35-
namespace,
38+
dynamic: false,
39+
},
40+
settings: {
41+
auto_expand_replicas: '0-1',
42+
hidden: true,
43+
...(useDataStream
44+
? {}
45+
: {
46+
'index.lifecycle': {
47+
name: 'test-ilm-policy',
48+
rollover_alias: `.alerts-test.alerts-${namespace}`,
49+
},
50+
}),
51+
'index.mapping.ignore_malformed': true,
52+
'index.mapping.total_fields.ignore_dynamic_beyond_limit': true,
53+
'index.mapping.total_fields.limit': 2500,
3654
},
37-
dynamic: false,
38-
},
39-
settings: {
40-
auto_expand_replicas: '0-1',
41-
hidden: true,
42-
...(useDataStream
43-
? {}
44-
: {
45-
'index.lifecycle': {
46-
name: 'test-ilm-policy',
47-
rollover_alias: `.alerts-test.alerts-${namespace}`,
48-
},
49-
}),
50-
'index.mapping.ignore_malformed': true,
51-
'index.mapping.total_fields.ignore_dynamic_beyond_limit': true,
52-
'index.mapping.total_fields.limit': 2500,
5355
},
56+
priority: namespace.length,
5457
},
55-
priority: namespace.length,
5658
});
5759

5860
const SimulateTemplateResponse = {

x-pack/platform/plugins/shared/alerting/server/alerts_service/lib/create_or_update_index_template.ts

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -57,40 +57,43 @@ export const getIndexTemplate = ({
5757

5858
return {
5959
name: indexPatterns.template,
60-
...(dataStreamFields.data_stream ? { data_stream: dataStreamFields.data_stream } : {}),
61-
index_patterns: dataStreamFields.index_patterns,
62-
composed_of: componentTemplateRefs,
63-
template: {
64-
settings: {
65-
auto_expand_replicas: '0-1',
66-
hidden: true,
67-
...(dataStreamAdapter.isUsingDataStreams()
68-
? {}
69-
: {
70-
'index.lifecycle': indexLifecycle,
71-
}),
72-
'index.mapping.ignore_malformed': true,
73-
'index.mapping.total_fields.limit': totalFieldsLimit,
74-
'index.mapping.total_fields.ignore_dynamic_beyond_limit': true,
75-
},
76-
mappings: {
77-
dynamic: false,
78-
_meta: indexMetadata,
79-
},
80-
...(indexPatterns.secondaryAlias
81-
? {
82-
aliases: {
83-
[indexPatterns.secondaryAlias]: {
84-
is_write_index: false,
60+
body: {
61+
...(dataStreamFields.data_stream ? { data_stream: dataStreamFields.data_stream } : {}),
62+
index_patterns: dataStreamFields.index_patterns,
63+
composed_of: componentTemplateRefs,
64+
template: {
65+
settings: {
66+
auto_expand_replicas: '0-1',
67+
hidden: true,
68+
...(dataStreamAdapter.isUsingDataStreams()
69+
? {}
70+
: {
71+
'index.lifecycle': indexLifecycle,
72+
}),
73+
'index.mapping.ignore_malformed': true,
74+
'index.mapping.total_fields.limit': totalFieldsLimit,
75+
'index.mapping.total_fields.ignore_dynamic_beyond_limit': true,
76+
},
77+
mappings: {
78+
dynamic: false,
79+
_meta: indexMetadata,
80+
},
81+
...(indexPatterns.secondaryAlias
82+
? {
83+
aliases: {
84+
[indexPatterns.secondaryAlias]: {
85+
is_write_index: false,
86+
},
8587
},
86-
},
87-
}
88-
: {}),
88+
}
89+
: {}),
90+
},
91+
_meta: indexMetadata,
92+
93+
// By setting the priority to namespace.length, we ensure that if one namespace is a prefix of another namespace
94+
// then newly created indices will use the matching template with the *longest* namespace
95+
priority: namespace.length,
8996
},
90-
_meta: indexMetadata,
91-
// By setting the priority to namespace.length, we ensure that if one namespace is a prefix of another namespace
92-
// then newly created indices will use the matching template with the *longest* namespace
93-
priority: namespace.length,
9497
};
9598
};
9699

0 commit comments

Comments
 (0)