Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -69,7 +70,7 @@ public SnapshotLifecycleTemplateRegistry(Settings nodeSettings, ClusterService c
}

@Override
protected List<IndexTemplateConfig> getLegacyTemplateConfigs() {
protected List<IndexTemplateConfig> getComposableTemplateConfigs() {
if (slmHistoryEnabled == false) {
return Collections.emptyList();
}
Expand All @@ -90,9 +91,9 @@ protected String getOrigin() {
}

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<Map<String, LifecyclePolicy>> maybePolicies = Optional
.<IndexLifecycleMetadata>ofNullable(state.metadata().custom(IndexLifecycleMetadata.TYPE))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ 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 String HISTORY_TEMPLATE_NAME = ".watch-history-" + INDEX_TEMPLATE_VERSION;
public static final String HISTORY_TEMPLATE_NAME_NO_ILM = ".watch-history-no-ilm-" + INDEX_TEMPLATE_VERSION;
public static final String TRIGGERED_TEMPLATE_NAME = ".triggered_watches";
Expand Down
149 changes: 75 additions & 74 deletions x-pack/plugin/core/src/main/resources/ilm-history.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,84 +2,85 @@
"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"
},
"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}
}
30 changes: 17 additions & 13 deletions x-pack/plugin/core/src/main/resources/slm-history.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -26,7 +26,7 @@
"repository": {
"type": "keyword"
},
"snapshot_name":{
"snapshot_name": {
"type": "keyword"
},
"operation": {
Expand Down Expand Up @@ -57,5 +57,9 @@
}
}
},
"_meta": {
"description": "index template for SLM history indices",
"managed": true
},
"version": ${xpack.slm.template.version}
}
28 changes: 16 additions & 12 deletions x-pack/plugin/core/src/main/resources/triggered-watches.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -37,5 +37,9 @@
}
}
},
"_meta": {
"description": "index template for triggered watches indices",
"managed": true
},
"version": ${xpack.watcher.template.version}
}
Loading