Browse Source

Remove watcher history clean up from monitoring (#67154)

Monitoring should not clean up watcher history - indices are managed by ILM policy now.
It was deprecated in 7.x, removing it now in 8
Przemko Robakowski 4 years ago
parent
commit
6dfdacdc8f

+ 0 - 15
docs/reference/settings/notification-settings.asciidoc

@@ -42,21 +42,6 @@ Specifies the path to a file that contains a key for encrypting sensitive data.
 If `xpack.watcher.encrypt_sensitive_data` is set to `true`, this setting is
 required. For more information, see <<encrypting-data>>.
 
-[[xpack-watcher-history-cleaner-service]]
-// tag::watcher-history-cleaner-service-tag[]
-`xpack.watcher.history.cleaner_service.enabled` {ess-icon}::
-(<<dynamic-cluster-setting,Dynamic>>)
-added:[6.3.0,Default changed to `true`.]
-deprecated:[7.0.0,Watcher history indices are now managed by the `watch-history-ilm-policy` ILM policy]
-+
-Set to `true` (default) to enable the cleaner service. The cleaner service
-removes previous versions of {watcher} indices (for example,
-`.watcher-history*`) when it determines that they are old. The duration of
-{watcher} indices is determined by the `xpack.monitoring.history.duration`
-setting, which defaults to 7 days. For more information about that setting,
-see <<monitoring-settings>>.
-// end::watcher-history-cleaner-service-tag[]
-
 `xpack.http.proxy.host`::
 (<<static-cluster-setting,Static>>)
 Specifies the address of the proxy server to use to connect to HTTP services.

+ 0 - 8
x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java

@@ -73,13 +73,6 @@ import static org.elasticsearch.common.settings.Setting.boolSetting;
 
 public class Monitoring extends Plugin implements ActionPlugin, ReloadablePlugin {
 
-    /**
-     * The ability to automatically cleanup ".watcher_history*" indices while also cleaning up Monitoring indices.
-     */
-    @Deprecated
-    public static final Setting<Boolean> CLEAN_WATCHER_HISTORY = boolSetting("xpack.watcher.history.cleaner_service.enabled",
-        true, Setting.Property.Dynamic, Setting.Property.NodeScope, Setting.Property.Deprecated);
-
     public static final Setting<Boolean> MIGRATION_DECOMMISSION_ALERTS = boolSetting("xpack.monitoring.migration.decommission_alerts",
         false, Setting.Property.Dynamic, Setting.Property.NodeScope);
 
@@ -154,7 +147,6 @@ public class Monitoring extends Plugin implements ActionPlugin, ReloadablePlugin
     public List<Setting<?>> getSettings() {
         List<Setting<?>> settings = new ArrayList<>();
         settings.add(MonitoringField.HISTORY_DURATION);
-        settings.add(CLEAN_WATCHER_HISTORY);
         settings.add(MonitoringService.ENABLED);
         settings.add(MonitoringService.ELASTICSEARCH_COLLECTION_ENABLED);
         settings.add(MonitoringService.INTERVAL);

+ 2 - 5
x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporter.java

@@ -86,7 +86,6 @@ import static org.elasticsearch.xpack.core.monitoring.exporter.MonitoringTemplat
 import static org.elasticsearch.xpack.core.monitoring.exporter.MonitoringTemplateUtils.loadPipeline;
 import static org.elasticsearch.xpack.core.monitoring.exporter.MonitoringTemplateUtils.pipelineName;
 import static org.elasticsearch.xpack.core.monitoring.exporter.MonitoringTemplateUtils.templateName;
-import static org.elasticsearch.xpack.monitoring.Monitoring.CLEAN_WATCHER_HISTORY;
 
 public class LocalExporter extends Exporter implements ClusterStateListener, CleanerService.Listener, LicenseStateListener {
 
@@ -641,11 +640,9 @@ public class LocalExporter extends Exporter implements ClusterStateListener, Cle
             if (clusterState != null) {
                 final long expirationTimeMillis = expiration.toInstant().toEpochMilli();
                 final long currentTimeMillis = System.currentTimeMillis();
-                final boolean cleanUpWatcherHistory = clusterService.getClusterSettings().get(CLEAN_WATCHER_HISTORY);
 
-                // list of index patterns that we clean up; watcher history can be included
-                final String[] indexPatterns =
-                        cleanUpWatcherHistory ? new String[] { ".monitoring-*", ".watcher-history*" } : new String[] { ".monitoring-*" };
+                // list of index patterns that we clean up
+                final String[] indexPatterns = new String[] { ".monitoring-*" };
 
                 // Get the names of the current monitoring indices
                 final Set<String> currents = MonitoredSystem.allSystems()

+ 0 - 31
x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/local/LocalIndicesCleanerTests.java

@@ -13,7 +13,6 @@ import org.elasticsearch.common.util.CollectionUtils;
 import org.elasticsearch.plugins.Plugin;
 import org.elasticsearch.test.InternalSettingsPlugin;
 import org.elasticsearch.xpack.monitoring.cleaner.AbstractIndicesCleanerTestCase;
-import org.elasticsearch.xpack.monitoring.cleaner.CleanerService;
 import org.elasticsearch.xpack.monitoring.exporter.local.LocalExporter;
 
 import java.time.ZonedDateTime;
@@ -24,8 +23,6 @@ import static org.hamcrest.Matchers.equalTo;
 
 public class LocalIndicesCleanerTests extends AbstractIndicesCleanerTestCase {
 
-    private final boolean cleanUpWatcherHistory = randomBoolean();
-
     @Override
     protected Collection<Class<? extends Plugin>> nodePlugins() {
         return CollectionUtils.appendToCopy(super.nodePlugins(), InternalSettingsPlugin.class);
@@ -36,7 +33,6 @@ public class LocalIndicesCleanerTests extends AbstractIndicesCleanerTestCase {
         return Settings.builder()
                 .put(super.nodeSettings(nodeOrdinal))
                 .put("xpack.monitoring.exporters._local.type", LocalExporter.TYPE)
-                .put("xpack.watcher.history.cleaner_service.enabled", cleanUpWatcherHistory)
                 .build();
     }
 
@@ -59,31 +55,4 @@ public class LocalIndicesCleanerTests extends AbstractIndicesCleanerTestCase {
             assertThat(getSettingsResponse.getIndexToSettings().size(), equalTo(count));
         });
     }
-
-    public void testHandlesWatcherHistory() throws Exception {
-        internalCluster().startNode();
-
-        // Will be deleted (if we delete them)
-        createWatcherHistoryIndex(now().minusDays(7));
-        createWatcherHistoryIndex(now().minusDays(10), "6");
-        createWatcherHistoryIndex(now().minusDays(14), "3");
-        createWatcherHistoryIndex(now().minusDays(30), "2");
-        createWatcherHistoryIndex(now().minusYears(1), "1");
-        createWatcherHistoryIndex(now().minusDays(10), String.valueOf(Integer.MAX_VALUE));
-
-        // Won't be deleted
-        createWatcherHistoryIndex(now());
-
-        assertIndicesCount(7);
-
-        CleanerService.Listener listener = getListener();
-        listener.onCleanUpIndices(days(3));
-
-        if (cleanUpWatcherHistory) {
-            assertIndicesCount(1);
-        } else {
-            assertIndicesCount(7);
-        }
-    }
-
 }