[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@92e7695a2c
This commit is contained in:
Chris Earle 2016-11-03 16:45:19 -04:00 committed by GitHub
parent 1926193766
commit ac7b617f02
3 changed files with 5 additions and 4 deletions

View File

@ -60,7 +60,8 @@ public class BackwardsCompatibilityAliasesResource extends HttpResource {
request.startObject().startArray("actions"); request.startObject().startArray("actions");
for (Map.Entry<String, Object> e : indices.entrySet()) { for (Map.Entry<String, Object> e : indices.entrySet()) {
String index = e.getKey(); 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)) { if (false == aliasesForIndex(e.getValue()).contains(alias)) {
needNewAliases = true; needNewAliases = true;
addAlias(request, index, alias); addAlias(request, index, alias);

View File

@ -397,7 +397,8 @@ public class LocalExporter extends Exporter implements ClusterStateListener, Cle
for (IndexMetaData index : clusterState.metaData()) { for (IndexMetaData index : clusterState.metaData()) {
String name = index.getIndex().getName(); String name = index.getIndex().getName();
if (name.startsWith(".marvel-es-1-")) { 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 (index.getAliases().containsKey(alias)) continue;
if (request == null) { if (request == null) {
request = new IndicesAliasesRequest(); request = new IndicesAliasesRequest();

View File

@ -12,7 +12,6 @@ import com.squareup.okhttp.mockwebserver.MockWebServer;
import com.squareup.okhttp.mockwebserver.RecordedRequest; import com.squareup.okhttp.mockwebserver.RecordedRequest;
import org.elasticsearch.Version; import org.elasticsearch.Version;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.DocWriteRequest; import org.elasticsearch.action.DocWriteRequest;
import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse; import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse;
import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.bulk.BulkRequest;
@ -606,7 +605,7 @@ public class HttpExporterIT extends MonitoringIntegTestCase {
if (bwcIndexesExist) { if (bwcIndexesExist) {
int timestampIndexes = between(1, 100); int timestampIndexes = between(1, 100);
for (int i = 0; i < timestampIndexes; i++) { 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(); response.endObject();