Skip to content

Commit 6e6b948

Browse files
authored
Make watch history indices hidden (#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 #50251
1 parent 3950c3a commit 6e6b948

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
@@ -118,7 +118,6 @@ public class MetaDataCreateIndexService {
118118
* These index patterns will be converted to hidden indices, at which point they should be removed from this list.
119119
*/
120120
private static final CharacterRunAutomaton DOT_INDICES_EXCLUSIONS = new CharacterRunAutomaton(Regex.simpleMatchToAutomaton(
121-
".watch-history-*",
122121
".data-frame-notifications-*",
123122
".transform-notifications-*"
124123
));

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,6 @@ public void testValidateDotIndex() {
617617
public void testIndexNameExclusionsList() {
618618
// this test case should be removed when DOT_INDICES_EXCLUSIONS is empty
619619
List<String> excludedNames = Arrays.asList(
620-
".watch-history-" + randomAlphaOfLength(5).toLowerCase(Locale.ROOT),
621620
".data-frame-notifications-" + randomAlphaOfLength(5).toLowerCase(Locale.ROOT),
622621
".transform-notifications-" + randomAlphaOfLength(5).toLowerCase(Locale.ROOT)
623622
);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,8 @@ protected final IndexResponse index(String index, String id, String source) {
11461146
protected final RefreshResponse refresh(String... indices) {
11471147
waitForRelocation();
11481148
// TODO RANDOMIZE with flush?
1149-
RefreshResponse actionGet = client().admin().indices().prepareRefresh(indices).execute().actionGet();
1149+
RefreshResponse actionGet = client().admin().indices().prepareRefresh(indices)
1150+
.setIndicesOptions(IndicesOptions.STRICT_EXPAND_OPEN_HIDDEN_FORBID_CLOSED).execute().actionGet();
11501151
assertNoFailures(actionGet);
11511152
return actionGet;
11521153
}

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)