Skip to content

Commit 87d7a72

Browse files
authored
[8.x] Auto increase fields limit of the alert indices (elastic#216719) (elastic#218203)
# Backport This will backport the following commits from `main` to `8.x`: - [Auto increase fields limit of the alert indices (elastic#216719)](elastic#216719)
1 parent 7372a73 commit 87d7a72

File tree

16 files changed

+972
-25
lines changed

16 files changed

+972
-25
lines changed

x-pack/platform/plugins/shared/alerting/common/alert_schema/field_maps/component_template_from_field_map.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
* 2.0.
66
*/
77

8-
import type { ClusterPutComponentTemplateRequest } from '@elastic/elasticsearch/lib/api/types';
8+
import type {
9+
ClusterPutComponentTemplateRequest,
10+
MappingDynamicTemplate,
11+
} from '@elastic/elasticsearch/lib/api/types';
912
import { type FieldMap } from '@kbn/alerts-as-data-utils';
1013
import { mappingFromFieldMap } from './mapping_from_field_map';
1114

@@ -14,12 +17,14 @@ export interface GetComponentTemplateFromFieldMapOpts {
1417
fieldMap: FieldMap;
1518
includeSettings?: boolean;
1619
dynamic?: 'strict' | false;
20+
dynamicTemplates?: Array<Record<string, MappingDynamicTemplate>>;
1721
}
1822
export const getComponentTemplateFromFieldMap = ({
1923
name,
2024
fieldMap,
2125
dynamic,
2226
includeSettings,
27+
dynamicTemplates,
2328
}: GetComponentTemplateFromFieldMapOpts): ClusterPutComponentTemplateRequest => {
2429
return {
2530
name,
@@ -37,7 +42,10 @@ export const getComponentTemplateFromFieldMap = ({
3742
: {}),
3843
},
3944

40-
mappings: mappingFromFieldMap(fieldMap, dynamic ?? 'strict'),
45+
mappings: {
46+
...mappingFromFieldMap(fieldMap, dynamic ?? 'strict'),
47+
...(dynamicTemplates ? { dynamic_templates: dynamicTemplates } : {}),
48+
},
4149
},
4250
};
4351
};

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ const getIndexTemplatePutBody = (opts?: GetIndexTemplatePutBodyOpts) => {
175175
}),
176176
'index.mapping.ignore_malformed': true,
177177
'index.mapping.total_fields.limit': 2500,
178+
'index.mapping.total_fields.ignore_dynamic_beyond_limit': true,
178179
},
179180
mappings: {
180181
dynamic: false,
@@ -482,6 +483,7 @@ describe('Alerts Service', () => {
482483
settings: {
483484
...existingIndexTemplate.index_template.template?.settings,
484485
'index.mapping.total_fields.limit': 2500,
486+
'index.mapping.total_fields.ignore_dynamic_beyond_limit': true,
485487
},
486488
},
487489
},
@@ -916,6 +918,7 @@ describe('Alerts Service', () => {
916918
},
917919
}),
918920
'index.mapping.ignore_malformed': true,
921+
'index.mapping.total_fields.ignore_dynamic_beyond_limit': true,
919922
'index.mapping.total_fields.limit': 2500,
920923
},
921924
mappings: {

0 commit comments

Comments
 (0)