diff --git a/docs/en/settings/monitoring-settings.asciidoc b/docs/en/settings/monitoring-settings.asciidoc index 2cf8b7dcc81..c07d625af5e 100644 --- a/docs/en/settings/monitoring-settings.asciidoc +++ b/docs/en/settings/monitoring-settings.asciidoc @@ -75,10 +75,14 @@ Sets the timeout for collecting the recovery information. Defaults to `10s`. `xpack.monitoring.collection.interval`:: +Setting to `-1` to disable data collection has been deprecated. added[6.3.0, +Use `xpack.monitoring.collection.enabled` set to `false` instead.] + Controls how often data samples are collected. Defaults to `10s`. If you modify the collection interval, set the `xpack.monitoring.min_interval_seconds` -option in `kibana.yml` to the same value. Set to `-1` to temporarily disable -data collection. You can update this setting through the +option in `kibana.yml` to the same value. ++ +You can update this setting through the <>. `xpack.monitoring.history.duration`:: diff --git a/plugin/build.gradle b/plugin/build.gradle index 35d0d5bb80b..3804e7918bc 100644 --- a/plugin/build.gradle +++ b/plugin/build.gradle @@ -94,7 +94,6 @@ integTestCluster { // Integration tests are supposed to enable/disable exporters before/after each test setting 'xpack.monitoring.exporters._local.type', 'local' setting 'xpack.monitoring.exporters._local.enabled', 'false' - setting 'xpack.monitoring.collection.interval', '-1' setting 'xpack.security.authc.token.enabled', 'true' setting 'xpack.security.transport.ssl.enabled', 'true' setting 'xpack.security.transport.ssl.keystore.path', nodeKeystore.name diff --git a/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringService.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringService.java index b2af52cbd8a..9f27b439ce3 100644 --- a/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringService.java +++ b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringService.java @@ -5,12 +5,14 @@ */ package org.elasticsearch.xpack.monitoring; +import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.message.ParameterizedMessage; import org.apache.logging.log4j.util.Supplier; import org.elasticsearch.action.ActionListener; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.component.AbstractLifecycleComponent; +import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; @@ -38,6 +40,24 @@ import java.util.concurrent.atomic.AtomicBoolean; */ public class MonitoringService extends AbstractLifecycleComponent { + /** + * Log a deprecation warning if {@code value} is -1. + *

+ * This should be removed in 7.0. + * + * @param value The value being set for the collection interval. + */ + private static void deprecateMinusOne(final TimeValue value) { + if (TimeValue.MINUS_ONE.equals(value)) { + final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(MonitoringService.class)); + + deprecationLogger.deprecated( + "Setting [xpack.monitoring.collection.interval] to [-1] has been deprecated as the way to disable collection. Use " + + "[xpack.monitoring.collection.enabled] set to [false] instead." + ); + } + } + /** * Minimum value for sampling interval (1 second) */ @@ -57,6 +77,8 @@ public class MonitoringService extends AbstractLifecycleComponent { (s) -> { TimeValue value = TimeValue.parseTimeValue(s, null, "xpack.monitoring.collection.interval"); if (TimeValue.MINUS_ONE.equals(value) || value.millis() >= MIN_INTERVAL.millis()) { + deprecateMinusOne(value); + return value; } throw new IllegalArgumentException("Failed to parse monitoring interval [" + s + "], value must be >= " + MIN_INTERVAL); diff --git a/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringServiceTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringServiceTests.java index 2b3b6b5cb81..f262d56fac8 100644 --- a/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringServiceTests.java +++ b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringServiceTests.java @@ -107,6 +107,10 @@ public class MonitoringServiceTests extends ESTestCase { CountingExporter exporter = new CountingExporter(); monitoringService = new MonitoringService(settings, clusterService, threadPool, emptySet(), exporter); + assertWarnings( + "Setting [xpack.monitoring.collection.interval] to [-1] has been deprecated as the way to disable collection. Use " + + "[xpack.monitoring.collection.enabled] set to [false] instead."); + monitoringService.start(); assertBusy(() -> assertTrue(monitoringService.isStarted())); assertFalse("interval -1 does not start the monitoring execution", monitoringService.isMonitoringActive()); diff --git a/qa/rolling-upgrade/build.gradle b/qa/rolling-upgrade/build.gradle index df51c820a6a..f7816e954f7 100644 --- a/qa/rolling-upgrade/build.gradle +++ b/qa/rolling-upgrade/build.gradle @@ -131,7 +131,6 @@ subprojects { minimumMasterNodes = { 2 } clusterName = 'rolling-upgrade' waitCondition = waitWithAuth - setting 'xpack.monitoring.collection.interval', '-1' setting 'xpack.monitoring.exporters._http.type', 'http' setting 'xpack.monitoring.exporters._http.enabled', 'false' setting 'xpack.monitoring.exporters._http.auth.username', 'test_user' @@ -178,7 +177,6 @@ subprojects { minimumMasterNodes = { 2 } dataDir = { nodeNumber -> oldClusterTest.nodes[1].dataDir } waitCondition = waitWithAuth - setting 'xpack.monitoring.collection.interval', '-1' setting 'xpack.monitoring.exporters._http.type', 'http' setting 'xpack.monitoring.exporters._http.enabled', 'false' setting 'xpack.monitoring.exporters._http.auth.username', 'test_user' @@ -219,7 +217,6 @@ subprojects { minimumMasterNodes = { 2 } dataDir = { nodeNumber -> oldClusterTest.nodes[0].dataDir } waitCondition = waitWithAuth - setting 'xpack.monitoring.collection.interval', '-1' setting 'xpack.monitoring.exporters._http.type', 'http' setting 'xpack.monitoring.exporters._http.enabled', 'false' setting 'xpack.monitoring.exporters._http.auth.username', 'test_user' diff --git a/qa/smoke-test-plugins-ssl/build.gradle b/qa/smoke-test-plugins-ssl/build.gradle index a4ceb257f39..96f1b8563c9 100644 --- a/qa/smoke-test-plugins-ssl/build.gradle +++ b/qa/smoke-test-plugins-ssl/build.gradle @@ -173,7 +173,7 @@ project.rootProject.subprojects.findAll { it.path.startsWith(':plugins:') }.each } integTestCluster { - setting 'xpack.monitoring.collection.interval', '3s' + setting 'xpack.monitoring.collection.interval', '1s' setting 'xpack.monitoring.exporters._http.type', 'http' setting 'xpack.monitoring.exporters._http.enabled', 'false' setting 'xpack.monitoring.exporters._http.ssl.truststore.path', clientKeyStore.name