From bb357f6aaea4b1abc46f010d57840087cf7f97bb Mon Sep 17 00:00:00 2001 From: Przemko Robakowski Date: Tue, 8 Sep 2020 11:26:06 +0200 Subject: [PATCH] [7.x] Move internal index templates to composable templates (#61457) (#61661) This change moves watcher, ILM history and SLM history templates to composable templates. Versions are updated to reflect the switch. Only change to the templates themselves is added `_meta` to mark them as managed --- .../SnapshotLifecycleTemplateRegistry.java | 9 +- .../WatcherIndexTemplateRegistryField.java | 8 +- .../core/src/main/resources/ilm-history.json | 152 ++--- .../core/src/main/resources/slm-history.json | 30 +- .../main/resources/triggered-watches-11.json | 41 ++ .../src/main/resources/triggered-watches.json | 28 +- .../src/main/resources/watch-history-11.json | 568 ++++++++++++++++ .../resources/watch-history-no-ilm-11.json | 617 ++++++++++++++++++ .../main/resources/watch-history-no-ilm.json | 386 +++++------ .../src/main/resources/watch-history.json | 346 +++++----- .../core/src/main/resources/watches-11.json | 63 ++ .../core/src/main/resources/watches.json | 114 ++-- ...napshotLifecycleTemplateRegistryTests.java | 44 +- .../xpack/ilm/ILMHistoryTests.java | 135 ++++ .../xpack/ilm/history/ILMHistoryStore.java | 2 + .../history/ILMHistoryTemplateRegistry.java | 5 +- .../AbstractWatcherIntegrationTestCase.java | 17 +- .../support/WatcherIndexTemplateRegistry.java | 62 +- .../WatcherIndexTemplateRegistryTests.java | 59 +- .../upgrades/WatcherRestartIT.java | 4 +- 20 files changed, 2103 insertions(+), 587 deletions(-) create mode 100644 x-pack/plugin/core/src/main/resources/triggered-watches-11.json create mode 100644 x-pack/plugin/core/src/main/resources/watch-history-11.json create mode 100644 x-pack/plugin/core/src/main/resources/watch-history-no-ilm-11.json create mode 100644 x-pack/plugin/core/src/main/resources/watches-11.json create mode 100644 x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/ilm/ILMHistoryTests.java diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/slm/history/SnapshotLifecycleTemplateRegistry.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/slm/history/SnapshotLifecycleTemplateRegistry.java index 908d469d0eb..0628dcc4b8f 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/slm/history/SnapshotLifecycleTemplateRegistry.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/slm/history/SnapshotLifecycleTemplateRegistry.java @@ -36,7 +36,8 @@ public class SnapshotLifecycleTemplateRegistry extends IndexTemplateRegistry { // history (please add a comment why you increased the version here) // version 1: initial // version 2: converted to hidden index - public static final int INDEX_TEMPLATE_VERSION = 2; + // version 3: templates moved to composable templates + public static final int INDEX_TEMPLATE_VERSION = 3; public static final String SLM_TEMPLATE_VERSION_VARIABLE = "xpack.slm.template.version"; public static final String SLM_TEMPLATE_NAME = ".slm-history"; @@ -69,7 +70,7 @@ public class SnapshotLifecycleTemplateRegistry extends IndexTemplateRegistry { } @Override - protected List getLegacyTemplateConfigs() { + protected List getComposableTemplateConfigs() { if (slmHistoryEnabled == false) { return Collections.emptyList(); } @@ -90,9 +91,9 @@ public class SnapshotLifecycleTemplateRegistry extends IndexTemplateRegistry { } public boolean validate(ClusterState state) { - boolean allTemplatesPresent = getLegacyTemplateConfigs().stream() + boolean allTemplatesPresent = getComposableTemplateConfigs().stream() .map(IndexTemplateConfig::getTemplateName) - .allMatch(name -> state.metadata().getTemplates().containsKey(name)); + .allMatch(name -> state.metadata().templatesV2().containsKey(name)); Optional> maybePolicies = Optional .ofNullable(state.metadata().custom(IndexLifecycleMetadata.TYPE)) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/WatcherIndexTemplateRegistryField.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/WatcherIndexTemplateRegistryField.java index 94fe152dc94..b71e12852ab 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/WatcherIndexTemplateRegistryField.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/WatcherIndexTemplateRegistryField.java @@ -16,15 +16,21 @@ public final class WatcherIndexTemplateRegistryField { // version 9: add a user field defining which user executed the watch // version 10: add support for foreach path in actions // version 11: watch history indices are hidden + // version 12: templates changed to composable templates // Note: if you change this, also inform the kibana team around the watcher-ui - public static final int INDEX_TEMPLATE_VERSION = 11; + public static final int INDEX_TEMPLATE_VERSION = 12; public static final int INDEX_TEMPLATE_VERSION_10 = 10; + public static final int INDEX_TEMPLATE_VERSION_11 = 11; public static final String HISTORY_TEMPLATE_NAME = ".watch-history-" + INDEX_TEMPLATE_VERSION; public static final String HISTORY_TEMPLATE_NAME_10 = ".watch-history-" + INDEX_TEMPLATE_VERSION_10; + public static final String HISTORY_TEMPLATE_NAME_11 = ".watch-history-" + INDEX_TEMPLATE_VERSION_11; public static final String HISTORY_TEMPLATE_NAME_NO_ILM = ".watch-history-no-ilm-" + INDEX_TEMPLATE_VERSION; public static final String HISTORY_TEMPLATE_NAME_NO_ILM_10 = ".watch-history-no-ilm-10"; + public static final String HISTORY_TEMPLATE_NAME_NO_ILM_11 = ".watch-history-no-ilm-" + INDEX_TEMPLATE_VERSION_11; public static final String TRIGGERED_TEMPLATE_NAME = ".triggered_watches"; + public static final String TRIGGERED_TEMPLATE_NAME_11 = ".triggered_watches-11"; public static final String WATCHES_TEMPLATE_NAME = ".watches"; + public static final String WATCHES_TEMPLATE_NAME_11 = ".watches-11"; public static final String[] TEMPLATE_NAMES = new String[] { HISTORY_TEMPLATE_NAME, TRIGGERED_TEMPLATE_NAME, WATCHES_TEMPLATE_NAME }; diff --git a/x-pack/plugin/core/src/main/resources/ilm-history.json b/x-pack/plugin/core/src/main/resources/ilm-history.json index bb79af74f20..8fa18c742c2 100644 --- a/x-pack/plugin/core/src/main/resources/ilm-history.json +++ b/x-pack/plugin/core/src/main/resources/ilm-history.json @@ -2,84 +2,88 @@ "index_patterns": [ "ilm-history-${xpack.ilm_history.template.version}*" ], - "order": 2147483647, - "settings": { - "index.number_of_shards": 1, - "index.number_of_replicas": 0, - "index.auto_expand_replicas": "0-1", - "index.lifecycle.name": "ilm-history-ilm-policy", - "index.lifecycle.rollover_alias": "ilm-history-${xpack.ilm_history.template.version}", - "index.hidden": true, - "index.format": 1 - }, - "mappings": { - "_doc": { - "dynamic": false, - "properties": { - "@timestamp": { - "type": "date", - "format": "epoch_millis" - }, - "policy": { - "type": "keyword" - }, - "index": { - "type": "keyword" - }, - "index_age":{ - "type": "long" - }, - "success": { - "type": "boolean" - }, - "state": { - "type": "object", - "dynamic": true, - "properties": { - "phase": { - "type": "keyword" - }, - "action": { - "type": "keyword" - }, - "step": { - "type": "keyword" - }, - "failed_step": { - "type": "keyword" - }, - "is_auto-retryable_error": { - "type": "keyword" - }, - "creation_date": { - "type": "date", - "format": "epoch_millis" - }, - "phase_time": { - "type": "date", - "format": "epoch_millis" - }, - "action_time": { - "type": "date", - "format": "epoch_millis" - }, - "step_time": { - "type": "date", - "format": "epoch_millis" - }, - "phase_definition": { - "type": "text" - }, - "step_info": { - "type": "text" + "template": { + "settings": { + "index.number_of_shards": 1, + "index.number_of_replicas": 0, + "index.auto_expand_replicas": "0-1", + "index.lifecycle.name": "ilm-history-ilm-policy", + "index.lifecycle.rollover_alias": "ilm-history-${xpack.ilm_history.template.version}", + "index.hidden": true, + "index.format": 1 + }, + "mappings": { + "dynamic": false, + "properties": { + "@timestamp": { + "type": "date", + "format": "epoch_millis" + }, + "policy": { + "type": "keyword" + }, + "index": { + "type": "keyword" + }, + "index_age": { + "type": "long" + }, + "success": { + "type": "boolean" + }, + "state": { + "type": "object", + "dynamic": true, + "properties": { + "phase": { + "type": "keyword" + }, + "action": { + "type": "keyword" + }, + "step": { + "type": "keyword" + }, + "failed_step": { + "type": "keyword" + }, + "is_auto-retryable_error": { + "type": "keyword" + }, + "creation_date": { + "type": "date", + "format": "epoch_millis" + }, + "phase_time": { + "type": "date", + "format": "epoch_millis" + }, + "action_time": { + "type": "date", + "format": "epoch_millis" + }, + "step_time": { + "type": "date", + "format": "epoch_millis" + }, + "phase_definition": { + "type": "text" + }, + "step_info": { + "type": "text" + } } + }, + "error_details": { + "type": "text" } - }, - "error_details": { - "type": "text" } } - } }, + "_meta": { + "description": "index template for ILM history indices", + "managed": true + }, + "priority": 2147483647, "version": ${xpack.ilm_history.template.version} } diff --git a/x-pack/plugin/core/src/main/resources/slm-history.json b/x-pack/plugin/core/src/main/resources/slm-history.json index 7ddd995fb21..b9320c170ec 100644 --- a/x-pack/plugin/core/src/main/resources/slm-history.json +++ b/x-pack/plugin/core/src/main/resources/slm-history.json @@ -2,18 +2,18 @@ "index_patterns": [ ".slm-history-${xpack.slm.template.version}*" ], - "order": 2147483647, - "settings": { - "index.number_of_shards": 1, - "index.number_of_replicas": 0, - "index.auto_expand_replicas": "0-1", - "index.lifecycle.name": "slm-history-ilm-policy", - "index.lifecycle.rollover_alias": ".slm-history-${xpack.slm.template.version}", - "index.hidden": true, - "index.format": 1 - }, - "mappings": { - "_doc": { + "priority": 2147483647, + "template": { + "settings": { + "index.number_of_shards": 1, + "index.number_of_replicas": 0, + "index.auto_expand_replicas": "0-1", + "index.lifecycle.name": "slm-history-ilm-policy", + "index.lifecycle.rollover_alias": ".slm-history-${xpack.slm.template.version}", + "index.hidden": true, + "index.format": 1 + }, + "mappings": { "dynamic": false, "properties": { "@timestamp": { @@ -26,7 +26,7 @@ "repository": { "type": "keyword" }, - "snapshot_name":{ + "snapshot_name": { "type": "keyword" }, "operation": { @@ -57,5 +57,9 @@ } } }, + "_meta": { + "description": "index template for SLM history indices", + "managed": true + }, "version": ${xpack.slm.template.version} } diff --git a/x-pack/plugin/core/src/main/resources/triggered-watches-11.json b/x-pack/plugin/core/src/main/resources/triggered-watches-11.json new file mode 100644 index 00000000000..90601a5a5a9 --- /dev/null +++ b/x-pack/plugin/core/src/main/resources/triggered-watches-11.json @@ -0,0 +1,41 @@ +{ + "index_patterns": [ ".triggered_watches*" ], + "order": 2147483647, + "settings": { + "index.number_of_shards": 1, + "index.auto_expand_replicas": "0-1", + "index.refresh_interval" : "-1", + "index.format": 6, + "index.priority": 900 + }, + "mappings": { + "_doc": { + "dynamic" : "strict", + "properties": { + "trigger_event": { + "type": "object", + "dynamic": true, + "enabled" : false, + "properties": { + "schedule": { + "type": "object", + "dynamic": true, + "properties": { + "triggered_time": { + "type": "date" + }, + "scheduled_time": { + "type": "date" + } + } + } + } + }, + "state": { + "type": "keyword" + } + } + } + }, + "version": 11 +} diff --git a/x-pack/plugin/core/src/main/resources/triggered-watches.json b/x-pack/plugin/core/src/main/resources/triggered-watches.json index 28f3b0fea65..1cb43c51c6e 100644 --- a/x-pack/plugin/core/src/main/resources/triggered-watches.json +++ b/x-pack/plugin/core/src/main/resources/triggered-watches.json @@ -1,21 +1,21 @@ { "index_patterns": [ ".triggered_watches*" ], - "order": 2147483647, - "settings": { - "index.number_of_shards": 1, - "index.auto_expand_replicas": "0-1", - "index.refresh_interval" : "-1", - "index.format": 6, - "index.priority": 900 - }, - "mappings": { - "_doc": { - "dynamic" : "strict", + "priority": 2147483647, + "template": { + "settings": { + "index.number_of_shards": 1, + "index.auto_expand_replicas": "0-1", + "index.refresh_interval": "-1", + "index.format": 6, + "index.priority": 900 + }, + "mappings": { + "dynamic": "strict", "properties": { "trigger_event": { "type": "object", "dynamic": true, - "enabled" : false, + "enabled": false, "properties": { "schedule": { "type": "object", @@ -37,5 +37,9 @@ } } }, + "_meta": { + "description": "index template for triggered watches indices", + "managed": true + }, "version": ${xpack.watcher.template.version} } diff --git a/x-pack/plugin/core/src/main/resources/watch-history-11.json b/x-pack/plugin/core/src/main/resources/watch-history-11.json new file mode 100644 index 00000000000..0494047319a --- /dev/null +++ b/x-pack/plugin/core/src/main/resources/watch-history-11.json @@ -0,0 +1,568 @@ +{ + "index_patterns": [ ".watcher-history-11*" ], + "order": 2147483647, + "settings": { + "index.number_of_shards": 1, + "index.number_of_replicas": 0, + "index.auto_expand_replicas": "0-1", + "index.lifecycle.name": "watch-history-ilm-policy", + "index.hidden": true, + "index.format": 6 + }, + "mappings": { + "_doc": { + "_meta": { + "watcher-history-version": "11" + }, + "dynamic_templates": [ + { + "disabled_payload_fields": { + "path_match": "result\\.(input(\\..+)*|(transform(\\..+)*)|(actions\\.transform(\\..+)*))\\.payload", + "match_pattern": "regex", + "mapping": { + "type": "object", + "enabled": false + } + } + }, + { + "disabled_search_request_body_fields": { + "path_match": "result\\.(input(\\..+)*|(transform(\\..+)*)|(actions\\.transform(\\..+)*))\\.search\\.request\\.(body|template)", + "match_pattern": "regex", + "mapping": { + "type": "object", + "enabled": false + } + } + }, + { + "disabled_exception_fields": { + "path_match": "result\\.(input(\\..+)*|(transform(\\..+)*)|(actions\\.transform(\\..+)*)|actions)\\.error", + "match_pattern": "regex", + "mapping": { + "type": "object", + "enabled": false + } + } + }, + { + "disabled_jira_custom_fields": { + "path_match": "result.actions.jira.fields.customfield_*", + "mapping": { + "type": "object", + "enabled": false + } + } + } + ], + "dynamic": false, + "properties": { + "watch_id": { + "type": "keyword" + }, + "node": { + "type": "keyword" + }, + "trigger_event": { + "type": "object", + "dynamic": true, + "properties": { + "type" : { + "type" : "keyword" + }, + "triggered_time": { + "type": "date" + }, + "manual": { + "type": "object", + "dynamic": true, + "properties": { + "schedule": { + "type": "object", + "dynamic": true, + "properties": { + "scheduled_time": { + "type": "date" + } + } + } + } + }, + "schedule": { + "type": "object", + "dynamic": true, + "properties": { + "scheduled_time": { + "type": "date" + } + } + } + } + }, + "vars" : { + "type" : "object", + "enabled" : false + }, + "input": { + "type": "object", + "enabled": false + }, + "condition": { + "type": "object", + "enabled": false + }, + "state": { + "type": "keyword" + }, + "status": { + "type": "object", + "enabled" : false, + "dynamic" : true + }, + "messages": { + "type": "text" + }, + "user": { + "type": "text" + }, + "exception" : { + "type" : "object", + "enabled" : false + }, + "result": { + "type": "object", + "dynamic": true, + "properties": { + "execution_time": { + "type": "date" + }, + "execution_duration": { + "type": "long" + }, + "input": { + "type": "object", + "dynamic": true, + "properties": { + "type" : { + "type" : "keyword" + }, + "status" : { + "type" : "keyword" + }, + "payload" : { + "type" : "object", + "enabled" : false + }, + "search": { + "type": "object", + "dynamic": true, + "properties": { + "request": { + "type": "object", + "dynamic": true, + "properties": { + "search_type": { + "type": "keyword" + }, + "indices": { + "type": "keyword" + }, + "types": { + "type": "keyword" + } + } + } + } + }, + "http": { + "type": "object", + "dynamic": true, + "properties": { + "request": { + "type": "object", + "dynamic": true, + "properties": { + "path": { + "type": "keyword" + }, + "host": { + "type": "keyword" + } + } + } + } + } + } + }, + "condition" : { + "type" : "object", + "dynamic" : true, + "properties" : { + "type" : { + "type" : "keyword" + }, + "status" : { + "type" : "keyword" + }, + "met" : { + "type" : "boolean" + }, + "compare" : { + "type" : "object", + "enabled" : false + }, + "array_compare" : { + "type" : "object", + "enabled" : false + }, + "script" : { + "type" : "object", + "enabled" : false + } + } + }, + "transform" : { + "type" : "object", + "dynamic" : true, + "properties" : { + "type" : { + "type" : "keyword" + }, + "search" : { + "type" : "object", + "dynamic" : true, + "properties" : { + "request" : { + "type" : "object", + "dynamic" : true, + "properties" : { + "indices" : { + "type" : "keyword" + }, + "types" : { + "type" : "keyword" + } + } + } + } + } + } + }, + "actions": { + "type": "nested", + "include_in_parent": true, + "dynamic": true, + "properties": { + "id" : { + "type" : "keyword" + }, + "type" : { + "type" : "keyword" + }, + "status" : { + "type" : "keyword" + }, + "reason" : { + "type" : "keyword" + }, + "number_of_actions_executed": { + "type": "integer" + }, + "foreach" : { + "type": "object", + "enabled" : false + }, + "email": { + "type": "object", + "dynamic": true, + "properties": { + "message": { + "type": "object", + "dynamic": true, + "properties": { + "id": { + "type": "keyword" + }, + "from": { + "type": "keyword" + }, + "reply_to": { + "type": "keyword" + }, + "to": { + "type": "keyword" + }, + "cc": { + "type": "keyword" + }, + "bcc": { + "type": "keyword" + } + } + } + } + }, + "webhook": { + "type": "object", + "dynamic": true, + "properties": { + "request": { + "type": "object", + "dynamic": true, + "properties": { + "path": { + "type": "keyword" + }, + "host": { + "type": "keyword" + } + } + } + } + }, + "index": { + "type": "object", + "dynamic": true, + "properties": { + "response": { + "type": "object", + "dynamic": true, + "properties": { + "index": { + "type": "keyword" + }, + "type": { + "type": "keyword" + }, + "id": { + "type": "keyword" + } + } + } + } + }, + "jira" : { + "type": "object", + "dynamic": true, + "properties": { + "account": { + "type": "keyword" + }, + "reason": { + "type": "text" + }, + "request" : { + "type" : "object", + "enabled" : false + }, + "response" : { + "type" : "object", + "enabled" : false + }, + "fields": { + "type": "object", + "dynamic": true, + "properties": { + "summary": { + "type": "text" + }, + "description": { + "type": "text" + }, + "labels" : { + "type": "text" + }, + "project" : { + "type" : "object", + "dynamic" : true, + "properties" : { + "key" : { + "type" : "keyword" + }, + "id" : { + "type" : "keyword" + } + } + }, + "issuetype" : { + "type" : "object", + "dynamic" : true, + "properties" : { + "name" : { + "type": "keyword" + }, + "id" : { + "type" : "keyword" + } + } + } + } + }, + "result": { + "type": "object", + "dynamic": true, + "properties" : { + "id" : { + "type" : "keyword" + }, + "key" : { + "type" : "keyword" + }, + "self" : { + "type" : "keyword" + } + } + } + } + }, + "slack" : { + "type": "object", + "dynamic": true, + "properties": { + "account": { + "type": "keyword" + }, + "sent_messages": { + "type": "nested", + "include_in_parent": true, + "dynamic": true, + "properties": { + "status": { + "type": "keyword" + }, + "reason": { + "type": "text" + }, + "request" : { + "type" : "object", + "enabled" : false + }, + "response" : { + "type" : "object", + "enabled" : false + }, + "to" : { + "type": "keyword" + }, + "message" : { + "type" : "object", + "dynamic" : true, + "properties" : { + "from" : { + "type" : "text" + }, + "icon" : { + "type" : "keyword" + }, + "text" : { + "type" : "text" + }, + "attachments" : { + "type" : "nested", + "include_in_parent": true, + "dynamic" : true, + "properties" : { + "color" : { + "type" : "keyword" + }, + "fields" : { + "properties" : { + "value" : { + "type" : "text" + } + } + } + } + } + } + } + } + } + } + }, + "pagerduty" : { + "type": "object", + "dynamic": true, + "properties": { + "account": { + "type": "keyword" + }, + "sent_event": { + "type": "nested", + "include_in_parent": true, + "dynamic": true, + "properties": { + "reason": { + "type": "text" + }, + "request" : { + "type" : "object", + "enabled" : false + }, + "response" : { + "type" : "object", + "enabled" : false + }, + "event" : { + "type" : "object", + "dynamic" : true, + "properties" : { + "type" : { + "type" : "keyword" + }, + "client" : { + "type" : "text" + }, + "client_url" : { + "type" : "keyword" + }, + "account" : { + "type" : "keyword" + }, + "attach_payload" : { + "type" : "boolean" + }, + "incident_key" : { + "type" : "keyword" + }, + "description" : { + "type" : "text" + }, + "context" : { + "type" : "nested", + "include_in_parent": true, + "dynamic" : true, + "properties" : { + "type" : { + "type" : "keyword" + }, + "href" : { + "type" : "keyword" + }, + "src" : { + "type" : "keyword" + }, + "alt" : { + "type" : "text" + } + } + } + } + } + } + } + } + } + } + } + } + }, + "metadata": { + "type": "object", + "dynamic": true + } + } + } + }, + "version": 11 +} diff --git a/x-pack/plugin/core/src/main/resources/watch-history-no-ilm-11.json b/x-pack/plugin/core/src/main/resources/watch-history-no-ilm-11.json new file mode 100644 index 00000000000..2fbc63a50c4 --- /dev/null +++ b/x-pack/plugin/core/src/main/resources/watch-history-no-ilm-11.json @@ -0,0 +1,617 @@ +{ + "index_patterns": [ ".watcher-history-11*" ], + "order": 2147483646, + "settings": { + "index.number_of_shards": 1, + "index.number_of_replicas": 0, + "index.auto_expand_replicas": "0-1", + "index.hidden": true, + "index.format": 6 + }, + "mappings": { + "doc": { + "_meta": { + "watcher-history-version": "11" + }, + "dynamic_templates": [ + { + "disabled_payload_fields": { + "path_match": "result\\.(input(\\..+)*|(transform(\\..+)*)|(actions\\.transform(\\..+)*))\\.payload", + "match_pattern": "regex", + "mapping": { + "type": "object", + "enabled": false + } + } + }, + { + "disabled_search_request_body_fields": { + "path_match": "result\\.(input(\\..+)*|(transform(\\..+)*)|(actions\\.transform(\\..+)*))\\.search\\.request\\.(body|template)", + "match_pattern": "regex", + "mapping": { + "type": "object", + "enabled": false + } + } + }, + { + "disabled_exception_fields": { + "path_match": "result\\.(input(\\..+)*|(transform(\\..+)*)|(actions\\.transform(\\..+)*)|actions)\\.error", + "match_pattern": "regex", + "mapping": { + "type": "object", + "enabled": false + } + } + }, + { + "disabled_jira_custom_fields": { + "path_match": "result.actions.jira.fields.customfield_*", + "mapping": { + "type": "object", + "enabled": false + } + } + } + ], + "dynamic": false, + "properties": { + "watch_id": { + "type": "keyword" + }, + "node": { + "type": "keyword" + }, + "trigger_event": { + "type": "object", + "dynamic": true, + "properties": { + "type" : { + "type" : "keyword" + }, + "triggered_time": { + "type": "date" + }, + "manual": { + "type": "object", + "dynamic": true, + "properties": { + "schedule": { + "type": "object", + "dynamic": true, + "properties": { + "scheduled_time": { + "type": "date" + } + } + } + } + }, + "schedule": { + "type": "object", + "dynamic": true, + "properties": { + "scheduled_time": { + "type": "date" + } + } + } + } + }, + "vars" : { + "type" : "object", + "enabled" : false + }, + "input": { + "type": "object", + "enabled": false + }, + "condition": { + "type": "object", + "enabled": false + }, + "state": { + "type": "keyword" + }, + "status": { + "type": "object", + "enabled" : false, + "dynamic" : true + }, + "messages": { + "type": "text" + }, + "user": { + "type": "text" + }, + "exception" : { + "type" : "object", + "enabled" : false + }, + "result": { + "type": "object", + "dynamic": true, + "properties": { + "execution_time": { + "type": "date" + }, + "execution_duration": { + "type": "long" + }, + "input": { + "type": "object", + "dynamic": true, + "properties": { + "type" : { + "type" : "keyword" + }, + "status" : { + "type" : "keyword" + }, + "payload" : { + "type" : "object", + "enabled" : false + }, + "search": { + "type": "object", + "dynamic": true, + "properties": { + "request": { + "type": "object", + "dynamic": true, + "properties": { + "search_type": { + "type": "keyword" + }, + "indices": { + "type": "keyword" + }, + "types": { + "type": "keyword" + } + } + } + } + }, + "http": { + "type": "object", + "dynamic": true, + "properties": { + "request": { + "type": "object", + "dynamic": true, + "properties": { + "path": { + "type": "keyword" + }, + "host": { + "type": "keyword" + } + } + } + } + } + } + }, + "condition" : { + "type" : "object", + "dynamic" : true, + "properties" : { + "type" : { + "type" : "keyword" + }, + "status" : { + "type" : "keyword" + }, + "met" : { + "type" : "boolean" + }, + "compare" : { + "type" : "object", + "enabled" : false + }, + "array_compare" : { + "type" : "object", + "enabled" : false + }, + "script" : { + "type" : "object", + "enabled" : false + } + } + }, + "transform" : { + "type" : "object", + "dynamic" : true, + "properties" : { + "type" : { + "type" : "keyword" + }, + "search" : { + "type" : "object", + "dynamic" : true, + "properties" : { + "request" : { + "type" : "object", + "dynamic" : true, + "properties" : { + "indices" : { + "type" : "keyword" + }, + "types" : { + "type" : "keyword" + } + } + } + } + } + } + }, + "actions": { + "type": "nested", + "include_in_parent": true, + "dynamic": true, + "properties": { + "id" : { + "type" : "keyword" + }, + "type" : { + "type" : "keyword" + }, + "status" : { + "type" : "keyword" + }, + "reason" : { + "type" : "keyword" + }, + "email": { + "type": "object", + "dynamic": true, + "properties": { + "message": { + "type": "object", + "dynamic": true, + "properties": { + "id": { + "type": "keyword" + }, + "from": { + "type": "keyword" + }, + "reply_to": { + "type": "keyword" + }, + "to": { + "type": "keyword" + }, + "cc": { + "type": "keyword" + }, + "bcc": { + "type": "keyword" + } + } + } + } + }, + "webhook": { + "type": "object", + "dynamic": true, + "properties": { + "request": { + "type": "object", + "dynamic": true, + "properties": { + "path": { + "type": "keyword" + }, + "host": { + "type": "keyword" + } + } + } + } + }, + "index": { + "type": "object", + "dynamic": true, + "properties": { + "response": { + "type": "object", + "dynamic": true, + "properties": { + "index": { + "type": "keyword" + }, + "type": { + "type": "keyword" + }, + "id": { + "type": "keyword" + } + } + } + } + }, + "hipchat" : { + "type": "object", + "dynamic": true, + "properties": { + "account": { + "type": "keyword" + }, + "sent_messages": { + "type": "nested", + "include_in_parent": true, + "dynamic": true, + "properties": { + "status": { + "type": "keyword" + }, + "reason": { + "type": "text" + }, + "request" : { + "type" : "object", + "enabled" : false + }, + "response" : { + "type" : "object", + "enabled" : false + }, + "room" : { + "type": "keyword" + }, + "user" : { + "type": "keyword" + }, + "message" : { + "type" : "object", + "dynamic" : true, + "properties" : { + "message_format" : { + "type" : "keyword" + }, + "color" : { + "type" : "keyword" + }, + "notify" : { + "type" : "boolean" + }, + "message" : { + "type" : "text" + }, + "from" : { + "type" : "text" + } + } + } + } + } + } + }, + "jira" : { + "type": "object", + "dynamic": true, + "properties": { + "account": { + "type": "keyword" + }, + "reason": { + "type": "text" + }, + "request" : { + "type" : "object", + "enabled" : false + }, + "response" : { + "type" : "object", + "enabled" : false + }, + "fields": { + "type": "object", + "dynamic": true, + "properties": { + "summary": { + "type": "text" + }, + "description": { + "type": "text" + }, + "labels" : { + "type": "text" + }, + "project" : { + "type" : "object", + "dynamic" : true, + "properties" : { + "key" : { + "type" : "keyword" + }, + "id" : { + "type" : "keyword" + } + } + }, + "issuetype" : { + "type" : "object", + "dynamic" : true, + "properties" : { + "name" : { + "type": "keyword" + }, + "id" : { + "type" : "keyword" + } + } + } + } + }, + "result": { + "type": "object", + "dynamic": true, + "properties" : { + "id" : { + "type" : "keyword" + }, + "key" : { + "type" : "keyword" + }, + "self" : { + "type" : "keyword" + } + } + } + } + }, + "slack" : { + "type": "object", + "dynamic": true, + "properties": { + "account": { + "type": "keyword" + }, + "sent_messages": { + "type": "nested", + "include_in_parent": true, + "dynamic": true, + "properties": { + "status": { + "type": "keyword" + }, + "reason": { + "type": "text" + }, + "request" : { + "type" : "object", + "enabled" : false + }, + "response" : { + "type" : "object", + "enabled" : false + }, + "to" : { + "type": "keyword" + }, + "message" : { + "type" : "object", + "dynamic" : true, + "properties" : { + "from" : { + "type" : "text" + }, + "icon" : { + "type" : "keyword" + }, + "text" : { + "type" : "text" + }, + "attachments" : { + "type" : "nested", + "include_in_parent": true, + "dynamic" : true, + "properties" : { + "color" : { + "type" : "keyword" + }, + "fields" : { + "properties" : { + "value" : { + "type" : "text" + } + } + } + } + } + } + } + } + } + } + }, + "pagerduty" : { + "type": "object", + "dynamic": true, + "properties": { + "account": { + "type": "keyword" + }, + "sent_event": { + "type": "nested", + "include_in_parent": true, + "dynamic": true, + "properties": { + "reason": { + "type": "text" + }, + "request" : { + "type" : "object", + "enabled" : false + }, + "response" : { + "type" : "object", + "enabled" : false + }, + "event" : { + "type" : "object", + "dynamic" : true, + "properties" : { + "type" : { + "type" : "keyword" + }, + "client" : { + "type" : "text" + }, + "client_url" : { + "type" : "keyword" + }, + "account" : { + "type" : "keyword" + }, + "attach_payload" : { + "type" : "boolean" + }, + "incident_key" : { + "type" : "keyword" + }, + "description" : { + "type" : "text" + }, + "context" : { + "type" : "nested", + "include_in_parent": true, + "dynamic" : true, + "properties" : { + "type" : { + "type" : "keyword" + }, + "href" : { + "type" : "keyword" + }, + "src" : { + "type" : "keyword" + }, + "alt" : { + "type" : "text" + } + } + } + } + } + } + } + } + } + } + } + } + }, + "metadata": { + "type": "object", + "dynamic": true + } + } + } + }, + "version": 11 +} diff --git a/x-pack/plugin/core/src/main/resources/watch-history-no-ilm.json b/x-pack/plugin/core/src/main/resources/watch-history-no-ilm.json index 7b591050839..2f4433536d4 100644 --- a/x-pack/plugin/core/src/main/resources/watch-history-no-ilm.json +++ b/x-pack/plugin/core/src/main/resources/watch-history-no-ilm.json @@ -1,15 +1,15 @@ { "index_patterns": [ ".watcher-history-${xpack.watcher.template.version}*" ], - "order": 2147483646, - "settings": { - "index.number_of_shards": 1, - "index.number_of_replicas": 0, - "index.auto_expand_replicas": "0-1", - "index.hidden": true, - "index.format": 6 - }, - "mappings": { - "doc": { + "priority": 2147483646, + "template": { + "settings": { + "index.number_of_shards": 1, + "index.number_of_replicas": 0, + "index.auto_expand_replicas": "0-1", + "index.hidden": true, + "index.format": 6 + }, + "mappings": { "_meta": { "watcher-history-version": "${xpack.watcher.template.version}" }, @@ -46,7 +46,7 @@ }, { "disabled_jira_custom_fields": { - "path_match": "result.actions.jira.fields.customfield_*", + "path_match": "result.actions.jira.fields.customfield_*", "mapping": { "type": "object", "enabled": false @@ -66,8 +66,8 @@ "type": "object", "dynamic": true, "properties": { - "type" : { - "type" : "keyword" + "type": { + "type": "keyword" }, "triggered_time": { "type": "date" @@ -98,9 +98,9 @@ } } }, - "vars" : { - "type" : "object", - "enabled" : false + "vars": { + "type": "object", + "enabled": false }, "input": { "type": "object", @@ -115,8 +115,8 @@ }, "status": { "type": "object", - "enabled" : false, - "dynamic" : true + "enabled": false, + "dynamic": true }, "messages": { "type": "text" @@ -124,9 +124,9 @@ "user": { "type": "text" }, - "exception" : { - "type" : "object", - "enabled" : false + "exception": { + "type": "object", + "enabled": false }, "result": { "type": "object", @@ -142,15 +142,15 @@ "type": "object", "dynamic": true, "properties": { - "type" : { - "type" : "keyword" + "type": { + "type": "keyword" }, - "status" : { - "type" : "keyword" + "status": { + "type": "keyword" }, - "payload" : { - "type" : "object", - "enabled" : false + "payload": { + "type": "object", + "enabled": false }, "search": { "type": "object", @@ -193,53 +193,53 @@ } } }, - "condition" : { - "type" : "object", - "dynamic" : true, - "properties" : { - "type" : { - "type" : "keyword" + "condition": { + "type": "object", + "dynamic": true, + "properties": { + "type": { + "type": "keyword" }, - "status" : { - "type" : "keyword" + "status": { + "type": "keyword" }, - "met" : { - "type" : "boolean" + "met": { + "type": "boolean" }, - "compare" : { - "type" : "object", - "enabled" : false + "compare": { + "type": "object", + "enabled": false }, - "array_compare" : { - "type" : "object", - "enabled" : false + "array_compare": { + "type": "object", + "enabled": false }, - "script" : { - "type" : "object", - "enabled" : false + "script": { + "type": "object", + "enabled": false } } }, - "transform" : { - "type" : "object", - "dynamic" : true, - "properties" : { - "type" : { - "type" : "keyword" + "transform": { + "type": "object", + "dynamic": true, + "properties": { + "type": { + "type": "keyword" }, - "search" : { - "type" : "object", - "dynamic" : true, - "properties" : { - "request" : { - "type" : "object", - "dynamic" : true, - "properties" : { - "indices" : { - "type" : "keyword" + "search": { + "type": "object", + "dynamic": true, + "properties": { + "request": { + "type": "object", + "dynamic": true, + "properties": { + "indices": { + "type": "keyword" }, - "types" : { - "type" : "keyword" + "types": { + "type": "keyword" } } } @@ -252,17 +252,17 @@ "include_in_parent": true, "dynamic": true, "properties": { - "id" : { - "type" : "keyword" + "id": { + "type": "keyword" }, - "type" : { - "type" : "keyword" + "type": { + "type": "keyword" }, - "status" : { - "type" : "keyword" + "status": { + "type": "keyword" }, - "reason" : { - "type" : "keyword" + "reason": { + "type": "keyword" }, "email": { "type": "object", @@ -333,7 +333,7 @@ } } }, - "hipchat" : { + "hipchat": { "type": "object", "dynamic": true, "properties": { @@ -351,38 +351,38 @@ "reason": { "type": "text" }, - "request" : { - "type" : "object", - "enabled" : false + "request": { + "type": "object", + "enabled": false }, - "response" : { - "type" : "object", - "enabled" : false + "response": { + "type": "object", + "enabled": false }, - "room" : { + "room": { "type": "keyword" }, - "user" : { + "user": { "type": "keyword" }, - "message" : { - "type" : "object", - "dynamic" : true, - "properties" : { - "message_format" : { - "type" : "keyword" + "message": { + "type": "object", + "dynamic": true, + "properties": { + "message_format": { + "type": "keyword" }, - "color" : { - "type" : "keyword" + "color": { + "type": "keyword" }, - "notify" : { - "type" : "boolean" + "notify": { + "type": "boolean" }, - "message" : { - "type" : "text" + "message": { + "type": "text" }, - "from" : { - "type" : "text" + "from": { + "type": "text" } } } @@ -390,7 +390,7 @@ } } }, - "jira" : { + "jira": { "type": "object", "dynamic": true, "properties": { @@ -400,13 +400,13 @@ "reason": { "type": "text" }, - "request" : { - "type" : "object", - "enabled" : false + "request": { + "type": "object", + "enabled": false }, - "response" : { - "type" : "object", - "enabled" : false + "response": { + "type": "object", + "enabled": false }, "fields": { "type": "object", @@ -418,30 +418,30 @@ "description": { "type": "text" }, - "labels" : { + "labels": { "type": "text" }, - "project" : { - "type" : "object", - "dynamic" : true, - "properties" : { - "key" : { - "type" : "keyword" + "project": { + "type": "object", + "dynamic": true, + "properties": { + "key": { + "type": "keyword" }, - "id" : { - "type" : "keyword" + "id": { + "type": "keyword" } } }, - "issuetype" : { - "type" : "object", - "dynamic" : true, - "properties" : { - "name" : { + "issuetype": { + "type": "object", + "dynamic": true, + "properties": { + "name": { "type": "keyword" }, - "id" : { - "type" : "keyword" + "id": { + "type": "keyword" } } } @@ -450,21 +450,21 @@ "result": { "type": "object", "dynamic": true, - "properties" : { - "id" : { - "type" : "keyword" + "properties": { + "id": { + "type": "keyword" }, - "key" : { - "type" : "keyword" + "key": { + "type": "keyword" }, - "self" : { - "type" : "keyword" + "self": { + "type": "keyword" } } } } }, - "slack" : { + "slack": { "type": "object", "dynamic": true, "properties": { @@ -482,42 +482,42 @@ "reason": { "type": "text" }, - "request" : { - "type" : "object", - "enabled" : false + "request": { + "type": "object", + "enabled": false }, - "response" : { - "type" : "object", - "enabled" : false + "response": { + "type": "object", + "enabled": false }, - "to" : { + "to": { "type": "keyword" }, - "message" : { - "type" : "object", - "dynamic" : true, - "properties" : { - "from" : { - "type" : "text" + "message": { + "type": "object", + "dynamic": true, + "properties": { + "from": { + "type": "text" }, - "icon" : { - "type" : "keyword" + "icon": { + "type": "keyword" }, - "text" : { - "type" : "text" + "text": { + "type": "text" }, - "attachments" : { - "type" : "nested", + "attachments": { + "type": "nested", "include_in_parent": true, - "dynamic" : true, - "properties" : { - "color" : { - "type" : "keyword" + "dynamic": true, + "properties": { + "color": { + "type": "keyword" }, - "fields" : { - "properties" : { - "value" : { - "type" : "text" + "fields": { + "properties": { + "value": { + "type": "text" } } } @@ -529,7 +529,7 @@ } } }, - "pagerduty" : { + "pagerduty": { "type": "object", "dynamic": true, "properties": { @@ -544,55 +544,55 @@ "reason": { "type": "text" }, - "request" : { - "type" : "object", - "enabled" : false + "request": { + "type": "object", + "enabled": false }, - "response" : { - "type" : "object", - "enabled" : false + "response": { + "type": "object", + "enabled": false }, - "event" : { - "type" : "object", - "dynamic" : true, - "properties" : { - "type" : { - "type" : "keyword" + "event": { + "type": "object", + "dynamic": true, + "properties": { + "type": { + "type": "keyword" }, - "client" : { - "type" : "text" + "client": { + "type": "text" }, - "client_url" : { - "type" : "keyword" + "client_url": { + "type": "keyword" }, - "account" : { - "type" : "keyword" + "account": { + "type": "keyword" }, - "attach_payload" : { - "type" : "boolean" + "attach_payload": { + "type": "boolean" }, - "incident_key" : { - "type" : "keyword" + "incident_key": { + "type": "keyword" }, - "description" : { - "type" : "text" + "description": { + "type": "text" }, - "context" : { - "type" : "nested", + "context": { + "type": "nested", "include_in_parent": true, - "dynamic" : true, - "properties" : { - "type" : { - "type" : "keyword" + "dynamic": true, + "properties": { + "type": { + "type": "keyword" }, - "href" : { - "type" : "keyword" + "href": { + "type": "keyword" }, - "src" : { - "type" : "keyword" + "src": { + "type": "keyword" }, - "alt" : { - "type" : "text" + "alt": { + "type": "text" } } } @@ -613,5 +613,9 @@ } } }, + "_meta": { + "description": "index template for watcher history indices", + "managed": true + }, "version": ${xpack.watcher.template.version} } diff --git a/x-pack/plugin/core/src/main/resources/watch-history.json b/x-pack/plugin/core/src/main/resources/watch-history.json index 109ca95d751..c5b380165fd 100644 --- a/x-pack/plugin/core/src/main/resources/watch-history.json +++ b/x-pack/plugin/core/src/main/resources/watch-history.json @@ -1,16 +1,16 @@ { "index_patterns": [ ".watcher-history-${xpack.watcher.template.version}*" ], - "order": 2147483647, - "settings": { - "index.number_of_shards": 1, - "index.number_of_replicas": 0, - "index.auto_expand_replicas": "0-1", - "index.lifecycle.name": "watch-history-ilm-policy", - "index.hidden": true, - "index.format": 6 - }, - "mappings": { - "_doc": { + "priority": 2147483647, + "template": { + "settings": { + "index.number_of_shards": 1, + "index.number_of_replicas": 0, + "index.auto_expand_replicas": "0-1", + "index.lifecycle.name": "watch-history-ilm-policy", + "index.hidden": true, + "index.format": 6 + }, + "mappings": { "_meta": { "watcher-history-version": "${xpack.watcher.template.version}" }, @@ -47,7 +47,7 @@ }, { "disabled_jira_custom_fields": { - "path_match": "result.actions.jira.fields.customfield_*", + "path_match": "result.actions.jira.fields.customfield_*", "mapping": { "type": "object", "enabled": false @@ -67,8 +67,8 @@ "type": "object", "dynamic": true, "properties": { - "type" : { - "type" : "keyword" + "type": { + "type": "keyword" }, "triggered_time": { "type": "date" @@ -99,9 +99,9 @@ } } }, - "vars" : { - "type" : "object", - "enabled" : false + "vars": { + "type": "object", + "enabled": false }, "input": { "type": "object", @@ -116,8 +116,8 @@ }, "status": { "type": "object", - "enabled" : false, - "dynamic" : true + "enabled": false, + "dynamic": true }, "messages": { "type": "text" @@ -125,9 +125,9 @@ "user": { "type": "text" }, - "exception" : { - "type" : "object", - "enabled" : false + "exception": { + "type": "object", + "enabled": false }, "result": { "type": "object", @@ -143,15 +143,15 @@ "type": "object", "dynamic": true, "properties": { - "type" : { - "type" : "keyword" + "type": { + "type": "keyword" }, - "status" : { - "type" : "keyword" + "status": { + "type": "keyword" }, - "payload" : { - "type" : "object", - "enabled" : false + "payload": { + "type": "object", + "enabled": false }, "search": { "type": "object", @@ -194,53 +194,53 @@ } } }, - "condition" : { - "type" : "object", - "dynamic" : true, - "properties" : { - "type" : { - "type" : "keyword" + "condition": { + "type": "object", + "dynamic": true, + "properties": { + "type": { + "type": "keyword" }, - "status" : { - "type" : "keyword" + "status": { + "type": "keyword" }, - "met" : { - "type" : "boolean" + "met": { + "type": "boolean" }, - "compare" : { - "type" : "object", - "enabled" : false + "compare": { + "type": "object", + "enabled": false }, - "array_compare" : { - "type" : "object", - "enabled" : false + "array_compare": { + "type": "object", + "enabled": false }, - "script" : { - "type" : "object", - "enabled" : false + "script": { + "type": "object", + "enabled": false } } }, - "transform" : { - "type" : "object", - "dynamic" : true, - "properties" : { - "type" : { - "type" : "keyword" + "transform": { + "type": "object", + "dynamic": true, + "properties": { + "type": { + "type": "keyword" }, - "search" : { - "type" : "object", - "dynamic" : true, - "properties" : { - "request" : { - "type" : "object", - "dynamic" : true, - "properties" : { - "indices" : { - "type" : "keyword" + "search": { + "type": "object", + "dynamic": true, + "properties": { + "request": { + "type": "object", + "dynamic": true, + "properties": { + "indices": { + "type": "keyword" }, - "types" : { - "type" : "keyword" + "types": { + "type": "keyword" } } } @@ -253,24 +253,24 @@ "include_in_parent": true, "dynamic": true, "properties": { - "id" : { - "type" : "keyword" + "id": { + "type": "keyword" }, - "type" : { - "type" : "keyword" + "type": { + "type": "keyword" }, - "status" : { - "type" : "keyword" + "status": { + "type": "keyword" }, - "reason" : { - "type" : "keyword" + "reason": { + "type": "keyword" }, "number_of_actions_executed": { "type": "integer" }, - "foreach" : { + "foreach": { "type": "object", - "enabled" : false + "enabled": false }, "email": { "type": "object", @@ -341,7 +341,7 @@ } } }, - "jira" : { + "jira": { "type": "object", "dynamic": true, "properties": { @@ -351,13 +351,13 @@ "reason": { "type": "text" }, - "request" : { - "type" : "object", - "enabled" : false + "request": { + "type": "object", + "enabled": false }, - "response" : { - "type" : "object", - "enabled" : false + "response": { + "type": "object", + "enabled": false }, "fields": { "type": "object", @@ -369,30 +369,30 @@ "description": { "type": "text" }, - "labels" : { + "labels": { "type": "text" }, - "project" : { - "type" : "object", - "dynamic" : true, - "properties" : { - "key" : { - "type" : "keyword" + "project": { + "type": "object", + "dynamic": true, + "properties": { + "key": { + "type": "keyword" }, - "id" : { - "type" : "keyword" + "id": { + "type": "keyword" } } }, - "issuetype" : { - "type" : "object", - "dynamic" : true, - "properties" : { - "name" : { + "issuetype": { + "type": "object", + "dynamic": true, + "properties": { + "name": { "type": "keyword" }, - "id" : { - "type" : "keyword" + "id": { + "type": "keyword" } } } @@ -401,21 +401,21 @@ "result": { "type": "object", "dynamic": true, - "properties" : { - "id" : { - "type" : "keyword" + "properties": { + "id": { + "type": "keyword" }, - "key" : { - "type" : "keyword" + "key": { + "type": "keyword" }, - "self" : { - "type" : "keyword" + "self": { + "type": "keyword" } } } } }, - "slack" : { + "slack": { "type": "object", "dynamic": true, "properties": { @@ -433,42 +433,42 @@ "reason": { "type": "text" }, - "request" : { - "type" : "object", - "enabled" : false + "request": { + "type": "object", + "enabled": false }, - "response" : { - "type" : "object", - "enabled" : false + "response": { + "type": "object", + "enabled": false }, - "to" : { + "to": { "type": "keyword" }, - "message" : { - "type" : "object", - "dynamic" : true, - "properties" : { - "from" : { - "type" : "text" + "message": { + "type": "object", + "dynamic": true, + "properties": { + "from": { + "type": "text" }, - "icon" : { - "type" : "keyword" + "icon": { + "type": "keyword" }, - "text" : { - "type" : "text" + "text": { + "type": "text" }, - "attachments" : { - "type" : "nested", + "attachments": { + "type": "nested", "include_in_parent": true, - "dynamic" : true, - "properties" : { - "color" : { - "type" : "keyword" + "dynamic": true, + "properties": { + "color": { + "type": "keyword" }, - "fields" : { - "properties" : { - "value" : { - "type" : "text" + "fields": { + "properties": { + "value": { + "type": "text" } } } @@ -480,7 +480,7 @@ } } }, - "pagerduty" : { + "pagerduty": { "type": "object", "dynamic": true, "properties": { @@ -495,55 +495,55 @@ "reason": { "type": "text" }, - "request" : { - "type" : "object", - "enabled" : false + "request": { + "type": "object", + "enabled": false }, - "response" : { - "type" : "object", - "enabled" : false + "response": { + "type": "object", + "enabled": false }, - "event" : { - "type" : "object", - "dynamic" : true, - "properties" : { - "type" : { - "type" : "keyword" + "event": { + "type": "object", + "dynamic": true, + "properties": { + "type": { + "type": "keyword" }, - "client" : { - "type" : "text" + "client": { + "type": "text" }, - "client_url" : { - "type" : "keyword" + "client_url": { + "type": "keyword" }, - "account" : { - "type" : "keyword" + "account": { + "type": "keyword" }, - "attach_payload" : { - "type" : "boolean" + "attach_payload": { + "type": "boolean" }, - "incident_key" : { - "type" : "keyword" + "incident_key": { + "type": "keyword" }, - "description" : { - "type" : "text" + "description": { + "type": "text" }, - "context" : { - "type" : "nested", + "context": { + "type": "nested", "include_in_parent": true, - "dynamic" : true, - "properties" : { - "type" : { - "type" : "keyword" + "dynamic": true, + "properties": { + "type": { + "type": "keyword" }, - "href" : { - "type" : "keyword" + "href": { + "type": "keyword" }, - "src" : { - "type" : "keyword" + "src": { + "type": "keyword" }, - "alt" : { - "type" : "text" + "alt": { + "type": "text" } } } @@ -564,5 +564,9 @@ } } }, + "_meta": { + "description": "index template for watcher history indices", + "managed": true + }, "version": ${xpack.watcher.template.version} } diff --git a/x-pack/plugin/core/src/main/resources/watches-11.json b/x-pack/plugin/core/src/main/resources/watches-11.json new file mode 100644 index 00000000000..f696bdffaee --- /dev/null +++ b/x-pack/plugin/core/src/main/resources/watches-11.json @@ -0,0 +1,63 @@ +{ + "index_patterns": [ ".watches*" ], + "order": 2147483647, + "settings": { + "index.number_of_shards": 1, + "index.number_of_replicas": 0, + "index.auto_expand_replicas": "0-1", + "index.format": 6, + "index.priority": 800 + }, + "mappings": { + "_doc": { + "dynamic" : "strict", + "properties": { + "status": { + "type": "object", + "enabled" : false, + "dynamic" : true + }, + "trigger" : { + "type": "object", + "enabled" : false, + "dynamic" : true + }, + "input": { + "type": "object", + "enabled" : false, + "dynamic" : true + }, + "condition": { + "type": "object", + "enabled" : false, + "dynamic" : true + }, + "throttle_period": { + "type" : "keyword", + "index" : false, + "doc_values" : false + }, + "throttle_period_in_millis": { + "type" : "long", + "index" : false, + "doc_values" : false + }, + "transform": { + "type" : "object", + "enabled" : false, + "dynamic" : true + }, + "actions": { + "type" : "object", + "enabled" : false, + "dynamic" : true + }, + "metadata" : { + "type" : "object", + "dynamic": true + } + } + } + }, + "version": 11 +} diff --git a/x-pack/plugin/core/src/main/resources/watches.json b/x-pack/plugin/core/src/main/resources/watches.json index 5181dfdc864..ab9ba4b1d9e 100644 --- a/x-pack/plugin/core/src/main/resources/watches.json +++ b/x-pack/plugin/core/src/main/resources/watches.json @@ -1,63 +1,67 @@ { "index_patterns": [ ".watches*" ], - "order": 2147483647, - "settings": { - "index.number_of_shards": 1, - "index.number_of_replicas": 0, - "index.auto_expand_replicas": "0-1", - "index.format": 6, - "index.priority": 800 - }, - "mappings": { - "_doc": { - "dynamic" : "strict", + "priority": 2147483647, + "template": { + "settings": { + "index.number_of_shards": 1, + "index.number_of_replicas": 0, + "index.auto_expand_replicas": "0-1", + "index.format": 6, + "index.priority": 800 + }, + "mappings": { + "dynamic": "strict", "properties": { - "status": { - "type": "object", - "enabled" : false, - "dynamic" : true - }, - "trigger" : { - "type": "object", - "enabled" : false, - "dynamic" : true - }, - "input": { - "type": "object", - "enabled" : false, - "dynamic" : true - }, - "condition": { - "type": "object", - "enabled" : false, - "dynamic" : true - }, - "throttle_period": { - "type" : "keyword", - "index" : false, - "doc_values" : false - }, - "throttle_period_in_millis": { - "type" : "long", - "index" : false, - "doc_values" : false - }, - "transform": { - "type" : "object", - "enabled" : false, - "dynamic" : true - }, - "actions": { - "type" : "object", - "enabled" : false, - "dynamic" : true - }, - "metadata" : { - "type" : "object", - "dynamic": true + "status": { + "type": "object", + "enabled": false, + "dynamic": true + }, + "trigger": { + "type": "object", + "enabled": false, + "dynamic": true + }, + "input": { + "type": "object", + "enabled": false, + "dynamic": true + }, + "condition": { + "type": "object", + "enabled": false, + "dynamic": true + }, + "throttle_period": { + "type": "keyword", + "index": false, + "doc_values": false + }, + "throttle_period_in_millis": { + "type": "long", + "index": false, + "doc_values": false + }, + "transform": { + "type": "object", + "enabled": false, + "dynamic": true + }, + "actions": { + "type": "object", + "enabled": false, + "dynamic": true + }, + "metadata": { + "type": "object", + "dynamic": true + } } - } } }, + "_meta": { + "description": "index template for watches indices", + "managed": true + }, "version": ${xpack.watcher.template.version} } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/slm/history/SnapshotLifecycleTemplateRegistryTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/slm/history/SnapshotLifecycleTemplateRegistryTests.java index e97bb4cbde2..9bfe0442b84 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/slm/history/SnapshotLifecycleTemplateRegistryTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/slm/history/SnapshotLifecycleTemplateRegistryTests.java @@ -11,22 +11,20 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.ActionType; -import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateAction; -import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest; +import org.elasticsearch.action.admin.indices.template.put.PutComposableIndexTemplateAction; import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.cluster.ClusterChangedEvent; import org.elasticsearch.cluster.ClusterModule; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.block.ClusterBlocks; -import org.elasticsearch.cluster.metadata.IndexTemplateMetadata; +import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; import org.elasticsearch.cluster.metadata.Metadata; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.TriFunction; -import org.elasticsearch.common.collect.ImmutableOpenMap; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; @@ -105,7 +103,7 @@ public class SnapshotLifecycleTemplateRegistryTests extends ESTestCase { Settings settings = Settings.builder().put(SLM_HISTORY_INDEX_ENABLED_SETTING.getKey(), false).build(); SnapshotLifecycleTemplateRegistry disabledRegistry = new SnapshotLifecycleTemplateRegistry(settings, clusterService, threadPool, client, xContentRegistry); - assertThat(disabledRegistry.getLegacyTemplateConfigs(), hasSize(0)); + assertThat(disabledRegistry.getComposableTemplateConfigs(), hasSize(0)); assertThat(disabledRegistry.getPolicyConfigs(), hasSize(0)); } @@ -119,7 +117,7 @@ public class SnapshotLifecycleTemplateRegistryTests extends ESTestCase { AtomicInteger calledTimes = new AtomicInteger(0); client.setVerifier((action, request, listener) -> verifyTemplateInstalled(calledTimes, action, request, listener)); registry.clusterChanged(event); - assertBusy(() -> assertThat(calledTimes.get(), equalTo(registry.getLegacyTemplateConfigs().size()))); + assertBusy(() -> assertThat(calledTimes.get(), equalTo(registry.getComposableTemplateConfigs().size()))); calledTimes.set(0); @@ -149,7 +147,7 @@ public class SnapshotLifecycleTemplateRegistryTests extends ESTestCase { assertThat(putRequest.getPolicy().getName(), equalTo(SLM_POLICY_NAME)); assertNotNull(listener); return new PutLifecycleAction.Response(true); - } else if (action instanceof PutIndexTemplateAction) { + } else if (action instanceof PutComposableIndexTemplateAction) { // Ignore this, it's verified in another test return new TestPutIndexTemplateResponse(true); } else { @@ -176,7 +174,7 @@ public class SnapshotLifecycleTemplateRegistryTests extends ESTestCase { policyMap.put(policy.getName(), policy); client.setVerifier((action, request, listener) -> { - if (action instanceof PutIndexTemplateAction) { + if (action instanceof PutComposableIndexTemplateAction) { // Ignore this, it's verified in another test return new TestPutIndexTemplateResponse(true); } else if (action instanceof PutLifecycleAction) { @@ -204,7 +202,7 @@ public class SnapshotLifecycleTemplateRegistryTests extends ESTestCase { LifecyclePolicy policy = policies.get(0); client.setVerifier((action, request, listener) -> { - if (action instanceof PutIndexTemplateAction) { + if (action instanceof PutComposableIndexTemplateAction) { // Ignore this, it's verified in another test return new TestPutIndexTemplateResponse(true); } else if (action instanceof PutLifecycleAction) { @@ -233,7 +231,7 @@ public class SnapshotLifecycleTemplateRegistryTests extends ESTestCase { AtomicInteger calledTimes = new AtomicInteger(0); client.setVerifier((action, request, listener) -> verifyTemplateInstalled(calledTimes, action, request, listener)); registry.clusterChanged(event); - assertBusy(() -> assertThat(calledTimes.get(), equalTo(registry.getLegacyTemplateConfigs().size()))); + assertBusy(() -> assertThat(calledTimes.get(), equalTo(registry.getComposableTemplateConfigs().size()))); } public void testThatUnversionedOldTemplatesAreUpgraded() throws Exception { @@ -244,7 +242,7 @@ public class SnapshotLifecycleTemplateRegistryTests extends ESTestCase { AtomicInteger calledTimes = new AtomicInteger(0); client.setVerifier((action, request, listener) -> verifyTemplateInstalled(calledTimes, action, request, listener)); registry.clusterChanged(event); - assertBusy(() -> assertThat(calledTimes.get(), equalTo(registry.getLegacyTemplateConfigs().size()))); + assertBusy(() -> assertThat(calledTimes.get(), equalTo(registry.getComposableTemplateConfigs().size()))); } @@ -256,7 +254,7 @@ public class SnapshotLifecycleTemplateRegistryTests extends ESTestCase { Collections.singletonMap(SLM_TEMPLATE_NAME, INDEX_TEMPLATE_VERSION), nodes); AtomicInteger calledTimes = new AtomicInteger(0); client.setVerifier((action, request, listener) -> { - if (action instanceof PutIndexTemplateAction) { + if (action instanceof PutComposableIndexTemplateAction) { fail("template should not have been re-installed"); return null; } else if (action instanceof PutLifecycleAction) { @@ -340,14 +338,14 @@ public class SnapshotLifecycleTemplateRegistryTests extends ESTestCase { private ActionResponse verifyTemplateInstalled( AtomicInteger calledTimes, ActionType action, ActionRequest request, ActionListener listener) { - if (action instanceof PutIndexTemplateAction) { + if (action instanceof PutComposableIndexTemplateAction) { calledTimes.incrementAndGet(); - assertThat(action, instanceOf(PutIndexTemplateAction.class)); - assertThat(request, instanceOf(PutIndexTemplateRequest.class)); - final PutIndexTemplateRequest putRequest = (PutIndexTemplateRequest) request; + assertThat(action, instanceOf(PutComposableIndexTemplateAction.class)); + assertThat(request, instanceOf(PutComposableIndexTemplateAction.Request.class)); + final PutComposableIndexTemplateAction.Request putRequest = (PutComposableIndexTemplateAction.Request) request; assertThat(putRequest.name(), equalTo(SLM_TEMPLATE_NAME)); - assertThat(putRequest.settings().get("index.lifecycle.name"), equalTo(SLM_POLICY_NAME)); - assertThat(putRequest.version(), equalTo(INDEX_TEMPLATE_VERSION)); + assertThat(putRequest.indexTemplate().template().settings().get("index.lifecycle.name"), equalTo(SLM_POLICY_NAME)); + assertThat(putRequest.indexTemplate().version(), equalTo((long) INDEX_TEMPLATE_VERSION)); assertNotNull(listener); return new TestPutIndexTemplateResponse(true); } else if (action instanceof PutLifecycleAction) { @@ -377,11 +375,11 @@ public class SnapshotLifecycleTemplateRegistryTests extends ESTestCase { private ClusterState createClusterState(Settings nodeSettings, Map existingTemplates, Map existingPolicies, DiscoveryNodes nodes) { - ImmutableOpenMap.Builder indexTemplates = ImmutableOpenMap.builder(); + Map indexTemplates = new HashMap<>(); for (Map.Entry template : existingTemplates.entrySet()) { - final IndexTemplateMetadata mockTemplate = mock(IndexTemplateMetadata.class); - when(mockTemplate.version()).thenReturn(template.getValue()); - when(mockTemplate.getVersion()).thenReturn(template.getValue()); + final ComposableIndexTemplate mockTemplate = mock(ComposableIndexTemplate.class); + Long version = template.getValue() == null ? null : (long) template.getValue(); + when(mockTemplate.version()).thenReturn(version); indexTemplates.put(template.getKey(), mockTemplate); } @@ -392,7 +390,7 @@ public class SnapshotLifecycleTemplateRegistryTests extends ESTestCase { return ClusterState.builder(new ClusterName("test")) .metadata(Metadata.builder() - .templates(indexTemplates.build()) + .indexTemplates(indexTemplates) .transientSettings(nodeSettings) .putCustom(IndexLifecycleMetadata.TYPE, ilmMeta) .build()) diff --git a/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/ilm/ILMHistoryTests.java b/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/ilm/ILMHistoryTests.java new file mode 100644 index 00000000000..01e04d70069 --- /dev/null +++ b/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/ilm/ILMHistoryTests.java @@ -0,0 +1,135 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +package org.elasticsearch.xpack.ilm; + +import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; +import org.elasticsearch.action.admin.indices.get.GetIndexResponse; +import org.elasticsearch.action.admin.indices.rollover.RolloverResponse; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.test.ESIntegTestCase; +import org.elasticsearch.xpack.core.LocalStateCompositeXPackPlugin; +import org.elasticsearch.xpack.core.XPackSettings; +import org.elasticsearch.xpack.core.ilm.LifecyclePolicy; +import org.elasticsearch.xpack.core.ilm.LifecycleSettings; +import org.elasticsearch.xpack.core.ilm.OperationMode; +import org.elasticsearch.xpack.core.ilm.Phase; +import org.elasticsearch.xpack.core.ilm.StopILMRequest; +import org.elasticsearch.xpack.core.ilm.action.GetStatusAction; +import org.elasticsearch.xpack.core.ilm.action.PutLifecycleAction; +import org.elasticsearch.xpack.core.ilm.action.StopILMAction; +import org.elasticsearch.xpack.ilm.history.ILMHistoryStore; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; + +import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS; +import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS; +import static org.elasticsearch.index.query.QueryBuilders.matchQuery; +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; +import static org.hamcrest.Matchers.arrayContaining; +import static org.hamcrest.Matchers.is; + +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0) +public class ILMHistoryTests extends ESIntegTestCase { + + @Override + protected Settings nodeSettings(int nodeOrdinal) { + Settings.Builder settings = Settings.builder().put(super.nodeSettings(nodeOrdinal)); + settings.put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), false); + settings.put(XPackSettings.SECURITY_ENABLED.getKey(), false); + settings.put(XPackSettings.WATCHER_ENABLED.getKey(), false); + settings.put(XPackSettings.GRAPH_ENABLED.getKey(), false); + settings.put(LifecycleSettings.LIFECYCLE_POLL_INTERVAL, "1s"); + settings.put(LifecycleSettings.SLM_HISTORY_INDEX_ENABLED_SETTING.getKey(), false); + return settings.build(); + } + + @Override + protected boolean ignoreExternalCluster() { + return true; + } + + @Override + protected Collection> nodePlugins() { + return Arrays.asList(LocalStateCompositeXPackPlugin.class, IndexLifecycle.class); + } + + @Override + protected Settings transportClientSettings() { + Settings.Builder settings = Settings.builder().put(super.transportClientSettings()); + settings.put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), false); + settings.put(XPackSettings.SECURITY_ENABLED.getKey(), false); + settings.put(XPackSettings.WATCHER_ENABLED.getKey(), false); + settings.put(XPackSettings.GRAPH_ENABLED.getKey(), false); + return settings.build(); + } + + @Override + protected Collection> transportClientPlugins() { + return nodePlugins(); + } + + private void putTestPolicy() throws InterruptedException, java.util.concurrent.ExecutionException { + Phase phase = new Phase("hot", TimeValue.ZERO, Collections.emptyMap()); + LifecyclePolicy lifecyclePolicy = new LifecyclePolicy("test", Collections.singletonMap("hot", phase)); + PutLifecycleAction.Request putLifecycleRequest = new PutLifecycleAction.Request(lifecyclePolicy); + PutLifecycleAction.Response putLifecycleResponse = client().execute(PutLifecycleAction.INSTANCE, putLifecycleRequest).get(); + assertAcked(putLifecycleResponse); + } + + public void testIlmHistoryIndexCanRollover() throws Exception { + putTestPolicy(); + Settings settings = Settings.builder().put(indexSettings()).put(SETTING_NUMBER_OF_SHARDS, 1) + .put(SETTING_NUMBER_OF_REPLICAS, 0).put(LifecycleSettings.LIFECYCLE_NAME, "test").build(); + CreateIndexResponse res = client().admin().indices().prepareCreate("test").setSettings(settings).get(); + assertTrue(res.isAcknowledged()); + + String firstIndex = ILMHistoryStore.ILM_HISTORY_INDEX_PREFIX + "000001"; + String secondIndex = ILMHistoryStore.ILM_HISTORY_INDEX_PREFIX + "000002"; + + assertBusy(() -> { + try { + GetIndexResponse getIndexResponse = client().admin().indices().prepareGetIndex().setIndices(firstIndex).get(); + assertThat(getIndexResponse.getIndices(), arrayContaining(firstIndex)); + } catch (Exception e) { + fail(e.getMessage()); + } + }); + + //wait for all history items to index to avoid waiting for timeout in ILMHistoryStore beforeBulk + assertBusy(() -> { + try { + SearchResponse search = client().prepareSearch(firstIndex).setQuery(matchQuery("index", firstIndex)).setSize(0).get(); + assertHitCount(search, 9); + } catch (Exception e) { + //assertBusy will stop on first non-assertion error and it can happen when we try to search too early + //instead of failing the whole test change it to assertion error and wait some more time + fail(e.getMessage()); + } + }); + + //make sure ILM is stopped so no new items will be queued in ILM history + assertTrue(client().execute(StopILMAction.INSTANCE, new StopILMRequest()).actionGet().isAcknowledged()); + assertBusy(() -> { + GetStatusAction.Response status = client().execute(GetStatusAction.INSTANCE, new GetStatusAction.Request()).actionGet(); + assertThat(status.getMode(), is(OperationMode.STOPPED)); + }); + + RolloverResponse rolloverResponse = client().admin().indices().prepareRolloverIndex(ILMHistoryStore.ILM_HISTORY_ALIAS).get(); + + assertTrue(rolloverResponse.isAcknowledged()); + assertThat(rolloverResponse.getNewIndex(), is(secondIndex)); + + GetIndexResponse getIndexResponse = client().admin().indices().prepareGetIndex().setIndices(secondIndex).get(); + assertThat(getIndexResponse.getIndices(), arrayContaining(secondIndex)); + } +} diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/history/ILMHistoryStore.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/history/ILMHistoryStore.java index 3c88fd270cd..275d128fb4f 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/history/ILMHistoryStore.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/history/ILMHistoryStore.java @@ -182,6 +182,8 @@ public class ILMHistoryStore implements Closeable { byte[] templateBytes = TEMPLATE_ILM_HISTORY.loadBytes(); Map templateAsMap = XContentHelper.convertToMap(new BytesArray(templateBytes, 0, templateBytes.length), false, XContentType.JSON).v2(); + templateAsMap = (Map) templateAsMap.get("template"); + client.admin().indices().prepareCreate(initialHistoryIndexName) .setSettings((Map) templateAsMap.get("settings")) diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/history/ILMHistoryTemplateRegistry.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/history/ILMHistoryTemplateRegistry.java index 323828e6e8a..08494b7fb70 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/history/ILMHistoryTemplateRegistry.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/history/ILMHistoryTemplateRegistry.java @@ -28,7 +28,8 @@ public class ILMHistoryTemplateRegistry extends IndexTemplateRegistry { // history (please add a comment why you increased the version here) // version 1: initial // version 2: convert to hidden index - public static final int INDEX_TEMPLATE_VERSION = 2; + // version 3: templates moved to composable templates + public static final int INDEX_TEMPLATE_VERSION = 3; public static final String ILM_TEMPLATE_VERSION_VARIABLE = "xpack.ilm_history.template.version"; public static final String ILM_TEMPLATE_NAME = "ilm-history"; @@ -62,7 +63,7 @@ public class ILMHistoryTemplateRegistry extends IndexTemplateRegistry { } @Override - protected List getLegacyTemplateConfigs() { + protected List getComposableTemplateConfigs() { if (this.ilmHistoryEnabled) { return Collections.singletonList(TEMPLATE_ILM_HISTORY); } else { diff --git a/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java b/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java index 4a2781bcd2b..6dcfeb8ffd1 100644 --- a/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java +++ b/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java @@ -11,7 +11,7 @@ import org.elasticsearch.action.admin.indices.alias.Alias; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesResponse; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; import org.elasticsearch.action.admin.indices.get.GetIndexResponse; -import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; +import org.elasticsearch.action.admin.indices.template.get.GetComposableIndexTemplateAction; import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.support.IndicesOptions; @@ -486,12 +486,15 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase private void ensureWatcherTemplatesAdded() throws Exception { // Verify that the index templates exist: assertBusy(() -> { - GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates(HISTORY_TEMPLATE_NAME).get(); - assertThat("[" + HISTORY_TEMPLATE_NAME + "] is missing", response.getIndexTemplates().size(), equalTo(1)); - response = client().admin().indices().prepareGetTemplates(TRIGGERED_TEMPLATE_NAME).get(); - assertThat("[" + TRIGGERED_TEMPLATE_NAME + "] is missing", response.getIndexTemplates().size(), equalTo(1)); - response = client().admin().indices().prepareGetTemplates(WATCHES_TEMPLATE_NAME).get(); - assertThat("[" + WATCHES_TEMPLATE_NAME + "] is missing", response.getIndexTemplates().size(), equalTo(1)); + GetComposableIndexTemplateAction.Response response = client().execute(GetComposableIndexTemplateAction.INSTANCE, + new GetComposableIndexTemplateAction.Request(HISTORY_TEMPLATE_NAME)).get(); + assertThat("[" + HISTORY_TEMPLATE_NAME + "] is missing", response.indexTemplates().size(), equalTo(1)); + response = client().execute(GetComposableIndexTemplateAction.INSTANCE, + new GetComposableIndexTemplateAction.Request(TRIGGERED_TEMPLATE_NAME)).get(); + assertThat("[" + TRIGGERED_TEMPLATE_NAME + "] is missing", response.indexTemplates().size(), equalTo(1)); + response = client().execute(GetComposableIndexTemplateAction.INSTANCE, + new GetComposableIndexTemplateAction.Request(WATCHES_TEMPLATE_NAME)).get(); + assertThat("[" + WATCHES_TEMPLATE_NAME + "] is missing", response.indexTemplates().size(), equalTo(1)); }); } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistry.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistry.java index 10f65524a25..2500856c6f1 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistry.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistry.java @@ -32,6 +32,11 @@ public class WatcherIndexTemplateRegistry extends IndexTemplateRegistry { "/triggered-watches.json", WatcherIndexTemplateRegistryField.INDEX_TEMPLATE_VERSION, WATCHER_TEMPLATE_VERSION_VARIABLE); + public static final IndexTemplateConfig TEMPLATE_CONFIG_TRIGGERED_WATCHES_11 = new IndexTemplateConfig( + WatcherIndexTemplateRegistryField.TRIGGERED_TEMPLATE_NAME_11, + "/triggered-watches-11.json", + 11, + WATCHER_TEMPLATE_VERSION_VARIABLE); public static final IndexTemplateConfig TEMPLATE_CONFIG_WATCH_HISTORY = new IndexTemplateConfig( WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME, "/watch-history.json", @@ -42,6 +47,11 @@ public class WatcherIndexTemplateRegistry extends IndexTemplateRegistry { "/watch-history-10.json", 10, WATCHER_TEMPLATE_VERSION_VARIABLE); + public static final IndexTemplateConfig TEMPLATE_CONFIG_WATCH_HISTORY_11 = new IndexTemplateConfig( + WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME_11, + "/watch-history-11.json", + 11, + WATCHER_TEMPLATE_VERSION_VARIABLE); public static final IndexTemplateConfig TEMPLATE_CONFIG_WATCH_HISTORY_NO_ILM = new IndexTemplateConfig( WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME_NO_ILM, "/watch-history-no-ilm.json", @@ -52,11 +62,21 @@ public class WatcherIndexTemplateRegistry extends IndexTemplateRegistry { "/watch-history-no-ilm-10.json", 10, WATCHER_TEMPLATE_VERSION_VARIABLE); + public static final IndexTemplateConfig TEMPLATE_CONFIG_WATCH_HISTORY_NO_ILM_11 = new IndexTemplateConfig( + WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME_NO_ILM_11, + "/watch-history-no-ilm-11.json", + 11, + WATCHER_TEMPLATE_VERSION_VARIABLE); public static final IndexTemplateConfig TEMPLATE_CONFIG_WATCHES = new IndexTemplateConfig( WatcherIndexTemplateRegistryField.WATCHES_TEMPLATE_NAME, "/watches.json", WatcherIndexTemplateRegistryField.INDEX_TEMPLATE_VERSION, WATCHER_TEMPLATE_VERSION_VARIABLE); + public static final IndexTemplateConfig TEMPLATE_CONFIG_WATCHES_11 = new IndexTemplateConfig( + WatcherIndexTemplateRegistryField.WATCHES_TEMPLATE_NAME_11, + "/watches-11.json", + 11, + WATCHER_TEMPLATE_VERSION_VARIABLE); public static final LifecyclePolicyConfig POLICY_WATCH_HISTORY = new LifecyclePolicyConfig("watch-history-ilm-policy", "/watch-history-ilm-policy.json"); @@ -71,21 +91,32 @@ public class WatcherIndexTemplateRegistry extends IndexTemplateRegistry { @Override protected List getLegacyTemplateConfigs() { - if (clusterService.state().nodes().getMinNodeVersion().onOrAfter(Version.V_7_7_0)) { + if (clusterService.state().nodes().getMinNodeVersion().onOrAfter(Version.V_7_9_0)) { + return Collections.emptyList(); + } else if (clusterService.state().nodes().getMinNodeVersion().onOrAfter(Version.V_7_7_0)) { return Arrays.asList( - ilmManagementEnabled ? TEMPLATE_CONFIG_WATCH_HISTORY : TEMPLATE_CONFIG_WATCH_HISTORY_NO_ILM, - TEMPLATE_CONFIG_TRIGGERED_WATCHES, - TEMPLATE_CONFIG_WATCHES + ilmManagementEnabled ? TEMPLATE_CONFIG_WATCH_HISTORY_11 : TEMPLATE_CONFIG_WATCH_HISTORY_NO_ILM_11, + TEMPLATE_CONFIG_TRIGGERED_WATCHES_11, + TEMPLATE_CONFIG_WATCHES_11 ); } else { return Arrays.asList( ilmManagementEnabled ? TEMPLATE_CONFIG_WATCH_HISTORY_10 : TEMPLATE_CONFIG_WATCH_HISTORY_NO_ILM_10, - TEMPLATE_CONFIG_TRIGGERED_WATCHES, - TEMPLATE_CONFIG_WATCHES + TEMPLATE_CONFIG_TRIGGERED_WATCHES_11, + TEMPLATE_CONFIG_WATCHES_11 ); } } + @Override + protected List getComposableTemplateConfigs() { + return Arrays.asList( + ilmManagementEnabled ? TEMPLATE_CONFIG_WATCH_HISTORY : TEMPLATE_CONFIG_WATCH_HISTORY_NO_ILM, + TEMPLATE_CONFIG_TRIGGERED_WATCHES, + TEMPLATE_CONFIG_WATCHES + ); + } + /** * If Watcher is configured not to use ILM, we don't return a policy. */ @@ -103,16 +134,21 @@ public class WatcherIndexTemplateRegistry extends IndexTemplateRegistry { } public static boolean validate(ClusterState state) { - if (state.nodes().getMinNodeVersion().onOrAfter(Version.V_7_7_0)) { - return (state.getMetadata().getTemplates().containsKey(WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME) || - state.getMetadata().getTemplates().containsKey(WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME_NO_ILM)) && - state.getMetadata().getTemplates().containsKey(WatcherIndexTemplateRegistryField.TRIGGERED_TEMPLATE_NAME) && - state.getMetadata().getTemplates().containsKey(WatcherIndexTemplateRegistryField.WATCHES_TEMPLATE_NAME); + if(state.nodes().getMinNodeVersion().onOrAfter(Version.V_7_9_0)){ + return (state.getMetadata().templatesV2().containsKey(WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME) || + state.getMetadata().templatesV2().containsKey(WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME_NO_ILM)) && + state.getMetadata().templatesV2().containsKey(WatcherIndexTemplateRegistryField.TRIGGERED_TEMPLATE_NAME) && + state.getMetadata().templatesV2().containsKey(WatcherIndexTemplateRegistryField.WATCHES_TEMPLATE_NAME); + } else if (state.nodes().getMinNodeVersion().onOrAfter(Version.V_7_7_0)) { + return (state.getMetadata().getTemplates().containsKey(WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME_11) || + state.getMetadata().getTemplates().containsKey(WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME_NO_ILM_11)) && + state.getMetadata().getTemplates().containsKey(WatcherIndexTemplateRegistryField.TRIGGERED_TEMPLATE_NAME_11) && + state.getMetadata().getTemplates().containsKey(WatcherIndexTemplateRegistryField.WATCHES_TEMPLATE_NAME_11); } else { return (state.getMetadata().getTemplates().containsKey(WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME_10) || state.getMetadata().getTemplates().containsKey(WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME_NO_ILM_10)) && - state.getMetadata().getTemplates().containsKey(WatcherIndexTemplateRegistryField.TRIGGERED_TEMPLATE_NAME) && - state.getMetadata().getTemplates().containsKey(WatcherIndexTemplateRegistryField.WATCHES_TEMPLATE_NAME); + state.getMetadata().getTemplates().containsKey(WatcherIndexTemplateRegistryField.TRIGGERED_TEMPLATE_NAME_11) && + state.getMetadata().getTemplates().containsKey(WatcherIndexTemplateRegistryField.WATCHES_TEMPLATE_NAME_11); } } diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java index 33bba097ba9..09e9fe798fa 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java @@ -7,6 +7,7 @@ package org.elasticsearch.xpack.watcher.support; import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.admin.indices.template.put.PutComposableIndexTemplateAction; import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest; import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.client.AdminClient; @@ -17,6 +18,7 @@ import org.elasticsearch.cluster.ClusterModule; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.block.ClusterBlocks; +import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; import org.elasticsearch.cluster.metadata.IndexTemplateMetadata; import org.elasticsearch.cluster.metadata.Metadata; import org.elasticsearch.cluster.node.DiscoveryNode; @@ -54,6 +56,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; import static org.elasticsearch.mock.orig.Mockito.verify; @@ -65,6 +68,8 @@ import static org.hamcrest.Matchers.is; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyObject; import static org.mockito.Matchers.eq; +import static org.mockito.Matchers.same; +import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @@ -114,8 +119,9 @@ public class WatcherIndexTemplateRegistryTests extends ESTestCase { ClusterChangedEvent event = createClusterChangedEvent(Collections.emptyMap(), nodes); registry.clusterChanged(event); - ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(PutIndexTemplateRequest.class); - verify(client.admin().indices(), times(3)).putTemplate(argumentCaptor.capture(), anyObject()); + ArgumentCaptor argumentCaptor = + ArgumentCaptor.forClass(PutComposableIndexTemplateAction.Request.class); + verify(client, times(3)).execute(same(PutComposableIndexTemplateAction.INSTANCE), argumentCaptor.capture(), anyObject()); // now delete one template from the cluster state and lets retry Map existingTemplates = new HashMap<>(); @@ -123,13 +129,13 @@ public class WatcherIndexTemplateRegistryTests extends ESTestCase { existingTemplates.put(WatcherIndexTemplateRegistryField.TRIGGERED_TEMPLATE_NAME, INDEX_TEMPLATE_VERSION); ClusterChangedEvent newEvent = createClusterChangedEvent(existingTemplates, nodes); registry.clusterChanged(newEvent); - ArgumentCaptor captor = ArgumentCaptor.forClass(PutIndexTemplateRequest.class); - verify(client.admin().indices(), times(4)).putTemplate(captor.capture(), anyObject()); - PutIndexTemplateRequest req = captor.getAllValues().stream() + argumentCaptor = ArgumentCaptor.forClass(PutComposableIndexTemplateAction.Request.class); + verify(client, times(3)).execute(same(PutComposableIndexTemplateAction.INSTANCE), argumentCaptor.capture(), anyObject()); + PutComposableIndexTemplateAction.Request req = argumentCaptor.getAllValues().stream() .filter(r -> r.name().equals(WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME)) .findFirst() .orElseThrow(() -> new AssertionError("expected the watch history template to be put")); - assertThat(req.settings().get("index.lifecycle.name"), equalTo("watch-history-ilm-policy")); + assertThat(req.indexTemplate().template().settings().get("index.lifecycle.name"), equalTo("watch-history-ilm-policy")); } public void testThatNonExistingTemplatesAreAddedEvenWithILMUsageDisabled() { @@ -141,8 +147,9 @@ public class WatcherIndexTemplateRegistryTests extends ESTestCase { clusterService, threadPool, client, xContentRegistry); ClusterChangedEvent event = createClusterChangedEvent(Settings.EMPTY, Collections.emptyMap(), Collections.emptyMap(), nodes); registry.clusterChanged(event); - ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(PutIndexTemplateRequest.class); - verify(client.admin().indices(), times(3)).putTemplate(argumentCaptor.capture(), anyObject()); + ArgumentCaptor argumentCaptor = + ArgumentCaptor.forClass(PutComposableIndexTemplateAction.Request.class); + verify(client, times(3)).execute(same(PutComposableIndexTemplateAction.INSTANCE), argumentCaptor.capture(), anyObject()); // now delete one template from the cluster state and lets retry Map existingTemplates = new HashMap<>(); @@ -151,7 +158,7 @@ public class WatcherIndexTemplateRegistryTests extends ESTestCase { ClusterChangedEvent newEvent = createClusterChangedEvent(existingTemplates, nodes); registry.clusterChanged(newEvent); ArgumentCaptor captor = ArgumentCaptor.forClass(PutIndexTemplateRequest.class); - verify(client.admin().indices(), times(5)).putTemplate(captor.capture(), anyObject()); + verify(client, times(3)).execute(same(PutComposableIndexTemplateAction.INSTANCE), argumentCaptor.capture(), anyObject()); captor.getAllValues().forEach(req -> assertNull(req.settings().get("index.lifecycle.name"))); verify(client, times(0)).execute(eq(PutLifecycleAction.INSTANCE), anyObject(), anyObject()); } @@ -262,9 +269,11 @@ public class WatcherIndexTemplateRegistryTests extends ESTestCase { ClusterChangedEvent event = createClusterChangedEvent(existingTemplates, nodes); registry.clusterChanged(event); - ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(PutIndexTemplateRequest.class); - verify(client.admin().indices(), times(1)).putTemplate(argumentCaptor.capture(), anyObject()); - assertThat(argumentCaptor.getValue().name(), is(WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME_10)); + ArgumentCaptor argumentCaptor = + ArgumentCaptor.forClass(PutComposableIndexTemplateAction.Request.class); + verify(client, times(3)).execute(same(PutComposableIndexTemplateAction.INSTANCE), argumentCaptor.capture(), anyObject()); + assertTrue(argumentCaptor.getAllValues().stream() + .anyMatch(r -> r.name().equals(WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME))); } public void testThatTemplatesWithHiddenAreAppliedOnNewerNodes() { @@ -280,8 +289,9 @@ public class WatcherIndexTemplateRegistryTests extends ESTestCase { registry.clusterChanged(event); ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(PutIndexTemplateRequest.class); - verify(client.admin().indices(), times(1)).putTemplate(argumentCaptor.capture(), anyObject()); - assertThat(argumentCaptor.getValue().name(), is(WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME_10)); + verify(client.admin().indices(), atLeastOnce()).putTemplate(argumentCaptor.capture(), anyObject()); + assertTrue(argumentCaptor.getAllValues().stream() + .anyMatch(i -> i.name().equals(WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME_10))); existingTemplates.remove(".watch-history-6"); existingTemplates.put(".watch-history-10", 10); @@ -291,8 +301,16 @@ public class WatcherIndexTemplateRegistryTests extends ESTestCase { registry.clusterChanged(event); argumentCaptor = ArgumentCaptor.forClass(PutIndexTemplateRequest.class); - verify(client.admin().indices(), times(2)).putTemplate(argumentCaptor.capture(), anyObject()); - assertThat(argumentCaptor.getValue().name(), is(WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME)); + verify(client.admin().indices(), atLeastOnce()).putTemplate(argumentCaptor.capture(), anyObject()); + assertTrue(argumentCaptor.getAllValues().stream() + .anyMatch(i -> i.name().equals(WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME_10))); + ArgumentCaptor captor = + ArgumentCaptor.forClass(PutComposableIndexTemplateAction.Request.class); + verify(client, atLeastOnce()).execute(same(PutComposableIndexTemplateAction.INSTANCE), captor.capture(), anyObject()); + Set templateNames = + captor.getAllValues().stream().map(PutComposableIndexTemplateAction.Request::name).collect(Collectors.toSet()); + assertTrue(templateNames.contains(WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME)); + assertFalse(templateNames.contains(WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME_10)); } public void testThatTemplatesAreNotAppliedOnSameVersionNodes() { @@ -376,11 +394,14 @@ public class WatcherIndexTemplateRegistryTests extends ESTestCase { private ClusterState createClusterState(Map existingTemplates) { Metadata.Builder metadataBuilder = Metadata.builder(); + HashMap templates = new HashMap<>(); for (Map.Entry template : existingTemplates.entrySet()) { - metadataBuilder.put(IndexTemplateMetadata.builder(template.getKey()) - .version(template.getValue()) - .patterns(Arrays.asList(generateRandomStringArray(10, 100, false, false)))); + ComposableIndexTemplate indexTemplate = mock(ComposableIndexTemplate.class); + when(indexTemplate.version()).thenReturn(template.getValue() == null ? null : (long) template.getValue()); + when(indexTemplate.indexPatterns()).thenReturn(Arrays.asList(generateRandomStringArray(10, 100, false, false))); + templates.put(template.getKey(), indexTemplate); } + metadataBuilder.indexTemplates(templates); return ClusterState.builder(new ClusterName("foo")).metadata(metadataBuilder.build()).build(); } diff --git a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/WatcherRestartIT.java b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/WatcherRestartIT.java index 35761b6f8bb..f3c39db0bc0 100644 --- a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/WatcherRestartIT.java +++ b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/WatcherRestartIT.java @@ -39,7 +39,7 @@ public class WatcherRestartIT extends AbstractUpgradeTestCase { // in a mixed cluster with some nodes <7.7.0 it will install template version 10, but if all nodes are <=7.7.0 template v11 // is used. final String expectedMixedClusterTemplate = templatePrefix + (UPGRADE_FROM_VERSION.before(Version.V_7_7_0) ? "10" : "11"); - final String expectedFinalTemplate = templatePrefix + "11"; + final String expectedFinalTemplate = templatePrefix + "12"; if (ClusterType.MIXED == CLUSTER_TYPE) { final Request request = new Request("HEAD", "/_template/" + expectedMixedClusterTemplate); @@ -50,7 +50,7 @@ public class WatcherRestartIT extends AbstractUpgradeTestCase { Response response = client().performRequest(request); assertThat(response.getStatusLine().getStatusCode(), is(200)); } else if (ClusterType.UPGRADED == CLUSTER_TYPE) { - Response response = client().performRequest(new Request("HEAD", "/_template/" + expectedFinalTemplate)); + Response response = client().performRequest(new Request("HEAD", "/_index_template/" + expectedFinalTemplate)); assertThat(response.getStatusLine().getStatusCode(), is(200)); } }