Skip to content

Commit 8a65a1a

Browse files
committed
Make watch history indices hidden (elastic#52962)
This commit updates the template used for watch history indices with the hidden index setting so that new indices will be created as hidden. Relates elastic#50251
1 parent b1be7dc commit 8a65a1a

File tree

7 files changed

+9
-4
lines changed

7 files changed

+9
-4
lines changed

server/src/main/java/org/elasticsearch/action/support/IndicesOptions.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ public enum Option {
126126
new IndicesOptions(EnumSet.of(Option.ALLOW_NO_INDICES), EnumSet.of(WildcardStates.OPEN, WildcardStates.CLOSED));
127127
public static final IndicesOptions STRICT_EXPAND_OPEN_FORBID_CLOSED =
128128
new IndicesOptions(EnumSet.of(Option.ALLOW_NO_INDICES, Option.FORBID_CLOSED_INDICES), EnumSet.of(WildcardStates.OPEN));
129+
public static final IndicesOptions STRICT_EXPAND_OPEN_HIDDEN_FORBID_CLOSED =
130+
new IndicesOptions(EnumSet.of(Option.ALLOW_NO_INDICES, Option.FORBID_CLOSED_INDICES),
131+
EnumSet.of(WildcardStates.OPEN, WildcardStates.HIDDEN));
129132
public static final IndicesOptions STRICT_EXPAND_OPEN_FORBID_CLOSED_IGNORE_THROTTLED =
130133
new IndicesOptions(EnumSet.of(Option.ALLOW_NO_INDICES, Option.FORBID_CLOSED_INDICES, Option.IGNORE_THROTTLED),
131134
EnumSet.of(WildcardStates.OPEN));

server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ public class MetaDataCreateIndexService {
120120
* These index patterns will be converted to hidden indices, at which point they should be removed from this list.
121121
*/
122122
private static final CharacterRunAutomaton DOT_INDICES_EXCLUSIONS = new CharacterRunAutomaton(Regex.simpleMatchToAutomaton(
123-
".watch-history-*",
124123
".data-frame-notifications-*",
125124
".transform-notifications-*"
126125
));

server/src/test/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexServiceTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,6 @@ public void testValidateDotIndex() {
641641
public void testIndexNameExclusionsList() {
642642
// this test case should be removed when DOT_INDICES_EXCLUSIONS is empty
643643
List<String> excludedNames = Arrays.asList(
644-
".watch-history-" + randomAlphaOfLength(5).toLowerCase(Locale.ROOT),
645644
".data-frame-notifications-" + randomAlphaOfLength(5).toLowerCase(Locale.ROOT),
646645
".transform-notifications-" + randomAlphaOfLength(5).toLowerCase(Locale.ROOT)
647646
);

test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,8 @@ protected final IndexResponse index(String index, String type, String id, String
12531253
protected final RefreshResponse refresh(String... indices) {
12541254
waitForRelocation();
12551255
// TODO RANDOMIZE with flush?
1256-
RefreshResponse actionGet = client().admin().indices().prepareRefresh(indices).execute().actionGet();
1256+
RefreshResponse actionGet = client().admin().indices().prepareRefresh(indices)
1257+
.setIndicesOptions(IndicesOptions.STRICT_EXPAND_OPEN_HIDDEN_FORBID_CLOSED).execute().actionGet();
12571258
assertNoFailures(actionGet);
12581259
return actionGet;
12591260
}

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/WatcherIndexTemplateRegistryField.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ public final class WatcherIndexTemplateRegistryField {
1515
// version 8: fix slack attachment property not to be dynamic, causing field type issues
1616
// version 9: add a user field defining which user executed the watch
1717
// version 10: add support for foreach path in actions
18+
// version 11: watch history indices are hidden
1819
// Note: if you change this, also inform the kibana team around the watcher-ui
19-
public static final int INDEX_TEMPLATE_VERSION = 10;
20+
public static final int INDEX_TEMPLATE_VERSION = 11;
2021
public static final String HISTORY_TEMPLATE_NAME = ".watch-history-" + INDEX_TEMPLATE_VERSION;
2122
public static final String HISTORY_TEMPLATE_NAME_NO_ILM = ".watch-history-no-ilm-" + INDEX_TEMPLATE_VERSION;
2223
public static final String TRIGGERED_TEMPLATE_NAME = ".triggered_watches";

x-pack/plugin/core/src/main/resources/watch-history-no-ilm.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"index.number_of_shards": 1,
66
"index.number_of_replicas": 0,
77
"index.auto_expand_replicas": "0-1",
8+
"index.hidden": true,
89
"index.format": 6
910
},
1011
"mappings": {

x-pack/plugin/core/src/main/resources/watch-history.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"index.number_of_replicas": 0,
77
"index.auto_expand_replicas": "0-1",
88
"index.lifecycle.name": "watch-history-ilm-policy",
9+
"index.hidden": true,
910
"index.format": 6
1011
},
1112
"mappings": {

0 commit comments

Comments
 (0)