From ac7b617f0205303be94b3397853b1ed6ee1c80c9 Mon Sep 17 00:00:00 2001 From: Chris Earle Date: Thu, 3 Nov 2016 16:45:19 -0400 Subject: [PATCH] [Monitoring] Use Suffix with Marvel Index alias (elastic/elasticsearch#3961) * [Monitoring] Use Suffix with Marvel Index alias Using a suffix allows a non-aliased Monitoring index get created for _today_. Otherwise the time-based index for today cannot be created. Original commit: elastic/x-pack-elasticsearch@92e7695a2c49e0e5caf2afe1cabdbc796bdff20a --- .../exporter/http/BackwardsCompatibilityAliasesResource.java | 3 ++- .../xpack/monitoring/exporter/local/LocalExporter.java | 3 ++- .../xpack/monitoring/exporter/http/HttpExporterIT.java | 3 +-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/BackwardsCompatibilityAliasesResource.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/BackwardsCompatibilityAliasesResource.java index 471b3ee4854..e251ac70757 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/BackwardsCompatibilityAliasesResource.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/BackwardsCompatibilityAliasesResource.java @@ -60,7 +60,8 @@ public class BackwardsCompatibilityAliasesResource extends HttpResource { request.startObject().startArray("actions"); for (Map.Entry e : indices.entrySet()) { String index = e.getKey(); - String alias = ".monitoring-es-2-" + index.substring(".marvel-es-1-".length()); + // we add a suffix so that it will not collide with today's monitoring index following an upgrade + String alias = ".monitoring-es-2-" + index.substring(".marvel-es-1-".length()) + "-alias"; if (false == aliasesForIndex(e.getValue()).contains(alias)) { needNewAliases = true; addAlias(request, index, alias); diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporter.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporter.java index 4c113ea4c99..76e23d01755 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporter.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporter.java @@ -397,7 +397,8 @@ public class LocalExporter extends Exporter implements ClusterStateListener, Cle for (IndexMetaData index : clusterState.metaData()) { String name = index.getIndex().getName(); if (name.startsWith(".marvel-es-1-")) { - String alias = ".monitoring-es-2-" + name.substring(".marvel-es-1-".length()); + // we add a suffix so that it will not collide with today's monitoring index following an upgrade + String alias = ".monitoring-es-2-" + name.substring(".marvel-es-1-".length()) + "-alias"; if (index.getAliases().containsKey(alias)) continue; if (request == null) { request = new IndicesAliasesRequest(); diff --git a/elasticsearch/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java b/elasticsearch/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java index 06cdc1c8828..ba9f1e796b7 100644 --- a/elasticsearch/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java +++ b/elasticsearch/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java @@ -12,7 +12,6 @@ import com.squareup.okhttp.mockwebserver.MockWebServer; import com.squareup.okhttp.mockwebserver.RecordedRequest; import org.elasticsearch.Version; -import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.DocWriteRequest; import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse; import org.elasticsearch.action.bulk.BulkRequest; @@ -606,7 +605,7 @@ public class HttpExporterIT extends MonitoringIntegTestCase { if (bwcIndexesExist) { int timestampIndexes = between(1, 100); for (int i = 0; i < timestampIndexes; i++) { - writeIndex(response, ".marvel-es-1-" + i, bwcAliasesExist ? ".monitoring-es-2-" + i : "ignored"); + writeIndex(response, ".marvel-es-1-" + i, bwcAliasesExist ? ".monitoring-es-2-" + i + "-alias" : "ignored"); } } response.endObject();