From f47fedd2a84400900ad5e81939788705c9d81d71 Mon Sep 17 00:00:00 2001 From: Jay Modi Date: Wed, 21 Oct 2020 08:58:24 -0600 Subject: [PATCH] Correct system index names in Kibana module (#63950) This commit updates the list of system index names to be complete and correct for Kibana and APM. The pattern `.kibana*` is too inclusive for system indices and actually includes the `.kibana-event-log-${version}-${int}` pattern for the Kibana event log, which should only be hidden and not a system index. Additionally, the `.apm-custom-link` index was not included in the list of system indices. Finally, the reporting pattern has been updated to match that of the permissions given to the kibana_system role. --- .../elasticsearch/kibana/KibanaSystemIndexIT.java | 7 ++++--- .../java/org/elasticsearch/kibana/KibanaPlugin.java | 2 +- .../org/elasticsearch/kibana/KibanaPluginTests.java | 12 ++++++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/modules/kibana/src/javaRestTest/java/org/elasticsearch/kibana/KibanaSystemIndexIT.java b/modules/kibana/src/javaRestTest/java/org/elasticsearch/kibana/KibanaSystemIndexIT.java index 92a4ee7d5b431..51af77c4565ea 100644 --- a/modules/kibana/src/javaRestTest/java/org/elasticsearch/kibana/KibanaSystemIndexIT.java +++ b/modules/kibana/src/javaRestTest/java/org/elasticsearch/kibana/KibanaSystemIndexIT.java @@ -47,9 +47,10 @@ public KibanaSystemIndexIT(@Name("indexName") String indexName) { public static Iterable data() { return Arrays.asList( new Object[] { ".kibana" }, - new Object[] { ".kibana-1" }, - new Object[] { ".reporting" }, - new Object[] { ".apm-agent-configuration" } + new Object[] { ".kibana_1" }, + new Object[] { ".reporting-1" }, + new Object[] { ".apm-agent-configuration" }, + new Object[] { ".apm-custom-link" } ); } diff --git a/modules/kibana/src/main/java/org/elasticsearch/kibana/KibanaPlugin.java b/modules/kibana/src/main/java/org/elasticsearch/kibana/KibanaPlugin.java index f6a09beab2fc2..43697f687971f 100644 --- a/modules/kibana/src/main/java/org/elasticsearch/kibana/KibanaPlugin.java +++ b/modules/kibana/src/main/java/org/elasticsearch/kibana/KibanaPlugin.java @@ -62,7 +62,7 @@ public class KibanaPlugin extends Plugin implements SystemIndexPlugin { public static final Setting> KIBANA_INDEX_NAMES_SETTING = Setting.listSetting( "kibana.system_indices", - List.of(".kibana*", ".reporting", ".apm-agent-configuration"), + List.of(".kibana", ".kibana_*", ".reporting-*", ".apm-agent-configuration", ".apm-custom-link"), Function.identity(), Property.NodeScope ); diff --git a/modules/kibana/src/test/java/org/elasticsearch/kibana/KibanaPluginTests.java b/modules/kibana/src/test/java/org/elasticsearch/kibana/KibanaPluginTests.java index 4e95b9b810317..07a490c5271e6 100644 --- a/modules/kibana/src/test/java/org/elasticsearch/kibana/KibanaPluginTests.java +++ b/modules/kibana/src/test/java/org/elasticsearch/kibana/KibanaPluginTests.java @@ -38,12 +38,20 @@ public void testKibanaIndexNames() { .stream() .map(SystemIndexDescriptor::getIndexPattern) .collect(Collectors.toUnmodifiableList()), - contains(".kibana*", ".reporting", ".apm-agent-configuration") + contains(".kibana", ".kibana_*", ".reporting-*", ".apm-agent-configuration", ".apm-custom-link") ); - final List names = List.of("." + randomAlphaOfLength(4), "." + randomAlphaOfLength(6)); + + final List names = List.of("." + randomAlphaOfLength(4), "." + randomAlphaOfLength(5)); final List namesFromDescriptors = new KibanaPlugin().getSystemIndexDescriptors( Settings.builder().putList(KibanaPlugin.KIBANA_INDEX_NAMES_SETTING.getKey(), names).build() ).stream().map(SystemIndexDescriptor::getIndexPattern).collect(Collectors.toUnmodifiableList()); assertThat(namesFromDescriptors, is(names)); + + assertThat( + new KibanaPlugin().getSystemIndexDescriptors(Settings.EMPTY) + .stream() + .anyMatch(systemIndexDescriptor -> systemIndexDescriptor.matchesIndexPattern(".kibana-event-log-7-1")), + is(false) + ); } }