diff --git a/docs/changelog/95481.yaml b/docs/changelog/95481.yaml new file mode 100644 index 0000000000000..2789566326fec --- /dev/null +++ b/docs/changelog/95481.yaml @@ -0,0 +1,6 @@ +pr: 95481 +summary: "Add support for `logs@custom` component template for `logs-*-* data streams" +area: Data streams +type: enhancement +issues: + - 95469 diff --git a/modules/data-streams/src/yamlRestTest/resources/rest-api-spec/test/data_stream/210_logs_custom_mappings.yml b/modules/data-streams/src/yamlRestTest/resources/rest-api-spec/test/data_stream/210_logs_custom_mappings.yml new file mode 100644 index 0000000000000..323dce3d32951 --- /dev/null +++ b/modules/data-streams/src/yamlRestTest/resources/rest-api-spec/test/data_stream/210_logs_custom_mappings.yml @@ -0,0 +1,37 @@ +--- +"Basic logs@custom component template functionality test": + - do: + cluster.put_component_template: + name: logs@custom + body: + template: + settings: + index: + query: + default_field: [ "custom-message" ] + mappings: + properties: + numeric_field: + type: integer + + - do: + indices.create_data_stream: + name: logs-generic-default + - is_true: acknowledged + + - do: + indices.get_data_stream: + name: logs-generic-default + - set: { data_streams.0.indices.0.index_name: idx0name } + + - do: + indices.get_settings: + index: $idx0name + # verify that the custom settings.index.query.default_field overrides the default query field - "message" + - match: { .$idx0name.settings.index.query.default_field: ["custom-message"] } + + - do: + indices.get_mapping: + index: $idx0name + # verify that the new field from the custom component template is applied + - match: { .$idx0name.mappings.properties.numeric_field.type: "integer" } diff --git a/x-pack/plugin/core/src/main/resources/logs-template.json b/x-pack/plugin/core/src/main/resources/logs-template.json index 198e0d04ab5af..6fb45b79ad2d7 100644 --- a/x-pack/plugin/core/src/main/resources/logs-template.json +++ b/x-pack/plugin/core/src/main/resources/logs-template.json @@ -5,8 +5,10 @@ "composed_of": [ "logs-mappings", "data-streams-mappings", - "logs-settings" + "logs-settings", + "logs@custom" ], + "ignore_missing_component_templates": ["logs@custom"], "allow_auto_create": true, "_meta": { "description": "default logs template installed by x-pack",