From f331cc8b641dc6bc4ce2ae82e404f88f0451d768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Mon, 20 Jul 2020 13:54:36 +0100 Subject: [PATCH] [Ingest Manager] Set `_meta` in the index.mappings (#72026) Co-authored-by: Elastic Machine --- .../__snapshots__/template.test.ts.snap | 21 +++++++++++++++++++ .../epm/elasticsearch/template/template.ts | 18 +++++++++------- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/__snapshots__/template.test.ts.snap b/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/__snapshots__/template.test.ts.snap index 219c2de675359..0333fb024a717 100644 --- a/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/__snapshots__/template.test.ts.snap +++ b/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/__snapshots__/template.test.ts.snap @@ -87,6 +87,13 @@ exports[`tests loading base.yml: base.yml 1`] = ` "validarray": { "type": "integer" } + }, + "_meta": { + "package": { + "name": "nginx" + }, + "managed_by": "ingest-manager", + "managed": true } }, "aliases": {} @@ -190,6 +197,13 @@ exports[`tests loading coredns.logs.yml: coredns.logs.yml 1`] = ` } } } + }, + "_meta": { + "package": { + "name": "coredns" + }, + "managed_by": "ingest-manager", + "managed": true } }, "aliases": {} @@ -1677,6 +1691,13 @@ exports[`tests loading system.yml: system.yml 1`] = ` } } } + }, + "_meta": { + "package": { + "name": "system" + }, + "managed_by": "ingest-manager", + "managed": true } }, "aliases": {} diff --git a/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/template.ts b/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/template.ts index 876573f2270ea..a739806d5868b 100644 --- a/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/template.ts +++ b/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/template.ts @@ -249,6 +249,15 @@ function getBaseTemplate( packageName: string, composedOfTemplates: string[] ): IndexTemplate { + // Meta information to identify Ingest Manager's managed templates and indices + const _meta = { + package: { + name: packageName, + }, + managed_by: 'ingest-manager', + managed: true, + }; + return { // This takes precedence over all index templates installed by ES by default (logs-*-* and metrics-*-*) // if this number is lower than the ES value (which is 100) this template will never be applied when a data stream @@ -304,19 +313,14 @@ function getBaseTemplate( date_detection: false, // All the properties we know from the fields.yml file properties: mappings.properties, + _meta, }, // To be filled with the aliases that we need aliases: {}, }, data_stream: {}, composed_of: composedOfTemplates, - _meta: { - package: { - name: packageName, - }, - managed_by: 'ingest-manager', - managed: true, - }, + _meta, }; }