Skip to content

Commit a81460d

Browse files
authored
Make watch history indices hidden (#52974)
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 Backport of #52962
1 parent a88d0c7 commit a81460d

File tree

14 files changed

+1283
-18
lines changed

14 files changed

+1283
-18
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/template/IndexTemplateRegistry.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public abstract class IndexTemplateRegistry implements ClusterStateListener {
5252
protected final Client client;
5353
protected final ThreadPool threadPool;
5454
protected final NamedXContentRegistry xContentRegistry;
55+
protected final ClusterService clusterService;
5556
protected final ConcurrentMap<String, AtomicBoolean> templateCreationsInProgress = new ConcurrentHashMap<>();
5657
protected final ConcurrentMap<String, AtomicBoolean> policyCreationsInProgress = new ConcurrentHashMap<>();
5758

@@ -61,6 +62,7 @@ public IndexTemplateRegistry(Settings nodeSettings, ClusterService clusterServic
6162
this.client = client;
6263
this.threadPool = threadPool;
6364
this.xContentRegistry = xContentRegistry;
65+
this.clusterService = clusterService;
6466
clusterService.addListener(this);
6567
}
6668

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ 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;
22+
public static final String HISTORY_TEMPLATE_NAME_10 = ".watch-history-10";
2123
public static final String HISTORY_TEMPLATE_NAME_NO_ILM = ".watch-history-no-ilm-" + INDEX_TEMPLATE_VERSION;
24+
public static final String HISTORY_TEMPLATE_NAME_NO_ILM_10 = ".watch-history-no-ilm-10";
2225
public static final String TRIGGERED_TEMPLATE_NAME = ".triggered_watches";
2326
public static final String WATCHES_TEMPLATE_NAME = ".watches";
2427
public static final String[] TEMPLATE_NAMES = new String[] {

0 commit comments

Comments
 (0)