[Monitoring] Ignore .marvel* indices (elastic/x-pack-elasticsearch#2520)

Beginning with 7.0, the cleaner service will no longer automatically cleanup .marvel indices regardless of their age.

Original commit: elastic/x-pack-elasticsearch@5b90e6f62a
This commit is contained in:
Chris Earle 2017-09-15 13:35:45 -07:00 committed by GitHub
parent 19de38665e
commit 24c2c62ca2
2 changed files with 4 additions and 9 deletions

View File

@ -506,9 +506,8 @@ public class LocalExporter extends Exporter implements ClusterStateListener, Cle
if (clusterState != null) { if (clusterState != null) {
long expirationTime = expiration.getMillis(); long expirationTime = expiration.getMillis();
// TODO: remove .marvel-* handling in 7.0 // list of index patterns that we clean up; we may add watcher history in the future
// Get the list of monitoring index patterns (note: this will include any unaliased .marvel-* indices) final String[] indexPatterns = new String[] { ".monitoring-*" };
final String[] monitoringIndexPatterns = new String[] { ".monitoring-*", ".marvel-*" };
MonitoringDoc monitoringDoc = new MonitoringDoc(null, null, null, null, null, MonitoringDoc monitoringDoc = new MonitoringDoc(null, null, null, null, null,
System.currentTimeMillis(), (MonitoringDoc.Node) null); System.currentTimeMillis(), (MonitoringDoc.Node) null);
@ -525,7 +524,7 @@ public class LocalExporter extends Exporter implements ClusterStateListener, Cle
for (ObjectObjectCursor<String, IndexMetaData> index : clusterState.getMetaData().indices()) { for (ObjectObjectCursor<String, IndexMetaData> index : clusterState.getMetaData().indices()) {
String indexName = index.key; String indexName = index.key;
if (Regex.simpleMatch(monitoringIndexPatterns, indexName)) { if (Regex.simpleMatch(indexPatterns, indexName)) {
// Never delete any "current" index (e.g., today's index or the most recent version no timestamp, like alerts) // Never delete any "current" index (e.g., today's index or the most recent version no timestamp, like alerts)
if (currents.contains(indexName)) { if (currents.contains(indexName)) {
continue; continue;

View File

@ -74,12 +74,8 @@ public abstract class AbstractIndicesCleanerTestCase extends MonitoringIntegTest
// Will be deleted // Will be deleted
createTimestampedIndex(now().minusDays(10)); createTimestampedIndex(now().minusDays(10));
createIndex(".marvel-es-data", now().minusYears(1));
createIndex(".marvel-es-data-2", now().minusYears(1));
createIndex(".monitoring-data-2", now().minusDays(10)); createIndex(".monitoring-data-2", now().minusDays(10));
createAlertsIndex(now().minusYears(1), MonitoringTemplateUtils.OLD_TEMPLATE_VERSION); createAlertsIndex(now().minusYears(1), MonitoringTemplateUtils.OLD_TEMPLATE_VERSION);
createIndex(".marvel-es-2016.05.03");
createIndex(".marvel-es-2-2016.05.03");
createTimestampedIndex(now().minusDays(10), "0"); createTimestampedIndex(now().minusDays(10), "0");
createTimestampedIndex(now().minusDays(10), "1"); createTimestampedIndex(now().minusDays(10), "1");
createTimestampedIndex(now().minusYears(1), MonitoringTemplateUtils.OLD_TEMPLATE_VERSION); createTimestampedIndex(now().minusYears(1), MonitoringTemplateUtils.OLD_TEMPLATE_VERSION);
@ -92,7 +88,7 @@ public abstract class AbstractIndicesCleanerTestCase extends MonitoringIntegTest
// Won't be deleted // Won't be deleted
createAlertsIndex(now().minusYears(1)); createAlertsIndex(now().minusYears(1));
assertIndicesCount(12); assertIndicesCount(8);
CleanerService.Listener listener = getListener(); CleanerService.Listener listener = getListener();
listener.onCleanUpIndices(days(0)); listener.onCleanUpIndices(days(0));