ソースを参照

Deprecate Monitoring Settings (#79499)

This PR deprecates all monitoring settings as well as adds deprecation info entries for each setting.

Collecting and shipping monitoring data using the Monitoring plugin will be deprecated in 7.16 and will be removed at some point in the 8.x line after sufficient wait time. The recommended approach for collecting and shipping monitoring data going forward is to use Metricbeat. The recommended approach for alerting is Kibana alerting.
James Baiera 4 年 前
コミット
12d10b07d7
38 ファイル変更662 行追加175 行削除
  1. 4 0
      docs/reference/monitoring/collecting-monitoring-data.asciidoc
  2. 5 0
      docs/reference/monitoring/configuring-metricbeat.asciidoc
  3. 1 0
      docs/reference/snapshot-restore/restore-snapshot.asciidoc
  4. 2 1
      test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java
  5. 0 3
      x-pack/docs/build.gradle
  6. 0 5
      x-pack/docs/src/test/java/org/elasticsearch/smoketest/XDocsClientYamlTestSuiteIT.java
  7. 0 2
      x-pack/plugin/build.gradle
  8. 3 0
      x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/monitoring/collector/ccr/StatsCollectorTests.java
  9. 1 1
      x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/MonitoringField.java
  10. 32 1
      x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java
  11. 225 0
      x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java
  12. 157 0
      x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java
  13. 5 0
      x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollectorTests.java
  14. 0 5
      x-pack/plugin/ml/qa/ml-with-security/src/yamlRestTest/java/org/elasticsearch/smoketest/MlWithSecurityIT.java
  15. 0 1
      x-pack/plugin/ml/qa/native-multi-node-tests/build.gradle
  16. 1 1
      x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java
  17. 3 3
      x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringService.java
  18. 3 2
      x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/Collector.java
  19. 2 1
      x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexRecoveryCollector.java
  20. 8 6
      x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporter.java
  21. 19 11
      x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporter.java
  22. 2 1
      x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporter.java
  23. 6 0
      x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringHistoryDurationSettingsTests.java
  24. 8 0
      x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringServiceTests.java
  25. 11 3
      x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/CleanerServiceTests.java
  26. 9 0
      x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollectorTests.java
  27. 11 0
      x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexRecoveryCollectorTests.java
  28. 6 0
      x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexStatsCollectorTests.java
  29. 6 0
      x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/ml/JobStatsCollectorTests.java
  30. 9 0
      x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsCollectorTests.java
  31. 3 0
      x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/shards/ShardsCollectorTests.java
  32. 6 0
      x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/ClusterAlertsUtilTests.java
  33. 21 0
      x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/ExportersTests.java
  34. 3 0
      x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterResourceTests.java
  35. 90 0
      x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterTests.java
  36. 0 105
      x-pack/plugin/src/test/java/org/elasticsearch/xpack/test/rest/AbstractXPackRestTest.java
  37. 0 5
      x-pack/plugin/text-structure/qa/text-structure-with-security/src/yamlRestTest/java/org/elasticsearch/smoketest/TextStructureWithSecurityIT.java
  38. 0 18
      x-pack/plugin/watcher/qa/with-monitoring/src/javaRestTest/java/org/elasticsearch/smoketest/MonitoringWithWatcherRestIT.java

+ 4 - 0
docs/reference/monitoring/collecting-monitoring-data.asciidoc

@@ -55,7 +55,10 @@ For example, use the following APIs to review and change this setting:
 [source,console]
 ----------------------------------
 GET _cluster/settings
+----------------------------------
 
+[source,console]
+----------------------------------
 PUT _cluster/settings
 {
   "persistent": {
@@ -63,6 +66,7 @@ PUT _cluster/settings
   }
 }
 ----------------------------------
+// TEST[warning:[xpack.monitoring.collection.enabled] setting was deprecated in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.]
 
 Alternatively, you can enable this setting in {kib}. In the side navigation,
 click *Monitoring*. If data collection is disabled, you are prompted to turn it

+ 5 - 0
docs/reference/monitoring/configuring-metricbeat.asciidoc

@@ -26,7 +26,10 @@ You can use the following APIs to review and change this setting:
 [source,console]
 ----------------------------------
 GET _cluster/settings
+----------------------------------
 
+[source,console]
+----------------------------------
 PUT _cluster/settings
 {
   "persistent": {
@@ -34,6 +37,7 @@ PUT _cluster/settings
   }
 }
 ----------------------------------
+// TEST[warning:[xpack.monitoring.collection.enabled] setting was deprecated in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.]
 
 If {es} {security-features} are enabled, you must have `monitor` cluster privileges to 
 view the cluster settings and `manage` cluster privileges to change them.
@@ -201,6 +205,7 @@ PUT _cluster/settings
   }
 }
 ----------------------------------
+// TEST[warning:[xpack.monitoring.elasticsearch.collection.enabled] setting was deprecated in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.]
 
 If {es} {security-features} are enabled, you must have `monitor` cluster
 privileges to view the cluster settings and `manage` cluster privileges

+ 1 - 0
docs/reference/snapshot-restore/restore-snapshot.asciidoc

@@ -277,6 +277,7 @@ PUT _cluster/settings
   }
 }
 ----
+// TEST[warning:[xpack.monitoring.collection.enabled] setting was deprecated in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.]
 // TEST[continued]
 ////
 

+ 2 - 1
test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java

@@ -927,7 +927,8 @@ public abstract class ESRestTestCase extends ESTestCase {
                 } else if (warnings.size() > 1) {
                     return true;
                 } else {
-                    return warnings.get(0).startsWith("[transient settings removal]") == false;
+                    return warnings.get(0).startsWith("[transient settings removal]") == false &&
+                        warnings.get(0).contains("xpack.monitoring") == false;
                 }
             }));
 

+ 0 - 3
x-pack/docs/build.gradle

@@ -34,9 +34,6 @@ testClusters.matching { it.name == "integTest" }.configureEach {
   setting 'xpack.security.enabled', 'true'
   setting 'xpack.security.authc.api_key.enabled', 'true'
   setting 'xpack.security.authc.token.enabled', 'true'
-  // Disable monitoring exporters for the docs tests
-  setting 'xpack.monitoring.exporters._local.type', 'local'
-  setting 'xpack.monitoring.exporters._local.enabled', 'false'
   // disable the ILM history for doc tests to avoid potential lingering tasks that'd cause test flakiness
   setting 'indices.lifecycle.history_index_enabled', 'false'
   setting 'xpack.license.self_generated.type', 'trial'

+ 0 - 5
x-pack/docs/src/test/java/org/elasticsearch/smoketest/XDocsClientYamlTestSuiteIT.java

@@ -120,11 +120,6 @@ public class XDocsClientYamlTestSuiteIT extends AbstractXPackRestTest {
         return testName != null && (testName.contains("watcher/") || testName.contains("watcher\\"));
     }
 
-    @Override
-    protected boolean isMonitoringTest() {
-        return false;
-    }
-
     @Override
     protected boolean isMachineLearningTest() {
         String testName = getTestName();

+ 0 - 2
x-pack/plugin/build.gradle

@@ -192,8 +192,6 @@ testClusters.configureEach {
   setting 'xpack.security.enabled', 'true'
   setting 'xpack.watcher.enabled', 'false'
   // 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.security.authc.token.enabled', 'true'
   setting 'xpack.security.authc.api_key.enabled', 'true'
   setting 'xpack.security.transport.ssl.enabled', 'true'

+ 3 - 0
x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/monitoring/collector/ccr/StatsCollectorTests.java

@@ -149,6 +149,9 @@ public class StatsCollectorTests extends BaseCollectorTestCase {
         assertThat(document.getType(), is(AutoFollowStatsMonitoringDoc.TYPE));
         assertThat(document.getId(), nullValue());
         assertThat(document.stats(), is(autoFollowStats));
+
+        assertWarnings("[xpack.monitoring.collection.ccr.stats.timeout] setting was deprecated in Elasticsearch and will be removed in " +
+            "a future release! See the breaking changes documentation for the next major version.");
     }
 
     private List<FollowStatsAction.StatsResponse> mockStatuses() {

+ 1 - 1
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/MonitoringField.java

@@ -31,7 +31,7 @@ public final class MonitoringField {
     public static final Setting<TimeValue> HISTORY_DURATION = timeSetting("xpack.monitoring.history.duration",
                                                       TimeValue.timeValueHours(7 * 24), // default value (7 days)
                                                       HISTORY_DURATION_MINIMUM,         // minimum value
-                                                      Setting.Property.Dynamic, Setting.Property.NodeScope);
+                                                      Setting.Property.Dynamic, Setting.Property.NodeScope, Setting.Property.Deprecated);
 
     private MonitoringField() {}
 }

+ 32 - 1
x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java

@@ -48,7 +48,38 @@ public class DeprecationChecks {
         NodeDeprecationChecks::checkSingleDataNodeWatermarkSetting,
         NodeDeprecationChecks::checkExporterUseIngestPipelineSettings,
         NodeDeprecationChecks::checkExporterPipelineMasterTimeoutSetting,
-        NodeDeprecationChecks::checkExporterCreateLegacyTemplateSetting
+        NodeDeprecationChecks::checkExporterCreateLegacyTemplateSetting,
+        NodeDeprecationChecks::checkMonitoringSettingHistoryDuration,
+        NodeDeprecationChecks::checkMonitoringSettingCollectIndexRecovery,
+        NodeDeprecationChecks::checkMonitoringSettingCollectIndices,
+        NodeDeprecationChecks::checkMonitoringSettingCollectCcrTimeout,
+        NodeDeprecationChecks::checkMonitoringSettingCollectEnrichStatsTimeout,
+        NodeDeprecationChecks::checkMonitoringSettingCollectIndexRecoveryStatsTimeout,
+        NodeDeprecationChecks::checkMonitoringSettingCollectIndexStatsTimeout,
+        NodeDeprecationChecks::checkMonitoringSettingCollectMlJobStatsTimeout,
+        NodeDeprecationChecks::checkMonitoringSettingCollectNodeStatsTimeout,
+        NodeDeprecationChecks::checkMonitoringSettingCollectClusterStatsTimeout,
+        NodeDeprecationChecks::checkMonitoringSettingExportersHost,
+        NodeDeprecationChecks::checkMonitoringSettingExportersBulkTimeout,
+        NodeDeprecationChecks::checkMonitoringSettingExportersConnectionTimeout,
+        NodeDeprecationChecks::checkMonitoringSettingExportersConnectionReadTimeout,
+        NodeDeprecationChecks::checkMonitoringSettingExportersAuthUsername,
+        NodeDeprecationChecks::checkMonitoringSettingExportersAuthPass,
+        NodeDeprecationChecks::checkMonitoringSettingExportersSSL,
+        NodeDeprecationChecks::checkMonitoringSettingExportersProxyBase,
+        NodeDeprecationChecks::checkMonitoringSettingExportersSniffEnabled,
+        NodeDeprecationChecks::checkMonitoringSettingExportersHeaders,
+        NodeDeprecationChecks::checkMonitoringSettingExportersTemplateTimeout,
+        NodeDeprecationChecks::checkMonitoringSettingExportersMasterTimeout,
+        NodeDeprecationChecks::checkMonitoringSettingExportersEnabled,
+        NodeDeprecationChecks::checkMonitoringSettingExportersType,
+        NodeDeprecationChecks::checkMonitoringSettingExportersAlertsEnabled,
+        NodeDeprecationChecks::checkMonitoringSettingExportersAlertsBlacklist,
+        NodeDeprecationChecks::checkMonitoringSettingExportersIndexNameTimeFormat,
+        NodeDeprecationChecks::checkMonitoringSettingDecommissionAlerts,
+        NodeDeprecationChecks::checkMonitoringSettingEsCollectionEnabled,
+        NodeDeprecationChecks::checkMonitoringSettingCollectionEnabled,
+        NodeDeprecationChecks::checkMonitoringSettingCollectionInterval
     );
 
     static List<Function<IndexMetadata, DeprecationIssue>> INDEX_SETTINGS_CHECKS = List.of(

+ 225 - 0
x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java

@@ -9,6 +9,7 @@ package org.elasticsearch.xpack.deprecation;
 
 import org.elasticsearch.action.admin.cluster.node.info.PluginsAndModules;
 import org.elasticsearch.cluster.routing.allocation.decider.DiskThresholdDecider;
+import org.elasticsearch.common.settings.SecureSetting;
 import org.elasticsearch.common.settings.Setting;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.env.Environment;
@@ -22,12 +23,28 @@ import java.util.Comparator;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Set;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 import static org.elasticsearch.xpack.core.security.authc.RealmSettings.RESERVED_REALM_NAME_PREFIX;
 
 public class NodeDeprecationChecks {
 
+    static DeprecationIssue checkDeprecatedSetting(final Settings settings, final Setting<?> deprecatedSetting, final String url,
+                                                   final String whenRemoved) {
+        if (deprecatedSetting.exists(settings) == false) {
+            return null;
+        }
+        final String deprecatedSettingKey = deprecatedSetting.getKey();
+        final String value = deprecatedSetting.get(settings).toString();
+        final String message =
+            String.format(Locale.ROOT, "setting [%s] is deprecated and will be removed " + whenRemoved, deprecatedSettingKey);
+        final String details =
+            String.format(Locale.ROOT, "the setting [%s] is currently set to [%s], remove this setting", deprecatedSettingKey, value);
+        return new DeprecationIssue(DeprecationIssue.Level.WARNING, message, url, details, false, null);
+    }
+
     static DeprecationIssue checkRemovedSetting(final Settings settings, final Setting<?> removedSetting, final String url) {
         if (removedSetting.exists(settings) == false) {
             return null;
@@ -116,6 +133,214 @@ public class NodeDeprecationChecks {
         return new DeprecationIssue(warningLevel, message, url, details, false, null);
     }
 
+    private static DeprecationIssue deprecatedAffixGroupedSetting(Setting.AffixSetting<Settings> deprecatedAffixSetting,
+                                                                  String detailPattern, String url, DeprecationIssue.Level warningLevel,
+                                                                  Settings settings) {
+        List<Setting<Settings>> deprecatedConcreteSettings = deprecatedAffixSetting.getAllConcreteSettings(settings)
+            .sorted(Comparator.comparing(Setting::getKey)).collect(Collectors.toList());
+
+        if (deprecatedConcreteSettings.isEmpty()) {
+            return null;
+        }
+
+        // The concrete setting names that are the root of the grouped settings (with asterisk appended for display)
+        final String groupSettingNames = deprecatedConcreteSettings.stream()
+            .map(Setting::getKey)
+            .map(key -> key + "*")
+            .collect(Collectors.joining(","));
+        // The actual group setting that are present in the settings object, with full setting name prepended.
+        String allSubSettings = deprecatedConcreteSettings.stream().map(affixSetting -> {
+            String groupPrefix = affixSetting.getKey();
+            Settings groupSettings = affixSetting.get(settings);
+            Set<String> subSettings = groupSettings.keySet();
+            return subSettings.stream().map(key -> groupPrefix + key).collect(Collectors.joining(","));
+        }).collect(Collectors.joining(";"));
+
+        final String message = String.format(
+            Locale.ROOT,
+            "The [%s] settings are deprecated and will be removed after 8.0",
+            groupSettingNames
+        );
+        final String details = String.format(Locale.ROOT, detailPattern, allSubSettings);
+
+        return new DeprecationIssue(warningLevel, message, url, details, false, null);
+    }
+
+    private static final String MONITORING_SETTING_DEPRECATION_LINK = "https://ela.st/es-deprecation-7-monitoring-settings";
+    private static final String MONITORING_SETTING_REMOVAL_TIME = "after 8.0";
+
+    static DeprecationIssue genericMonitoringSetting(final Settings settings, final Setting<?> deprecated) {
+        return checkDeprecatedSetting(settings, deprecated, MONITORING_SETTING_DEPRECATION_LINK, MONITORING_SETTING_REMOVAL_TIME);
+    }
+
+    static DeprecationIssue genericMonitoringAffixSetting(final Settings settings, final String deprecatedSuffix) {
+        return deprecatedAffixSetting(
+            Setting.affixKeySetting("xpack.monitoring.exporters.", deprecatedSuffix,
+                (Function<String, Setting<String>>) Setting::simpleString),
+            "Remove the following settings from elasticsearch.yml: [%s]",
+            MONITORING_SETTING_DEPRECATION_LINK,
+            DeprecationIssue.Level.WARNING,
+            settings);
+    }
+
+    static DeprecationIssue genericMonitoringAffixSecureSetting(final Settings settings, final String deprecatedSuffix) {
+        return deprecatedAffixSetting(
+            Setting.affixKeySetting("xpack.monitoring.exporters.", deprecatedSuffix,
+                k -> SecureSetting.secureString(k, null)),
+            "Remove the following settings from the keystore: [%s]",
+            MONITORING_SETTING_DEPRECATION_LINK,
+            DeprecationIssue.Level.WARNING,
+            settings);
+    }
+
+    static DeprecationIssue genericMonitoringAffixGroupedSetting(final Settings settings, final String deprecatedSuffix) {
+        return deprecatedAffixGroupedSetting(
+            Setting.affixKeySetting("xpack.monitoring.exporters.", deprecatedSuffix, k -> Setting.groupSetting(k + ".")),
+            "Remove the following settings from elasticsearch.yml: [%s]",
+            MONITORING_SETTING_DEPRECATION_LINK,
+            DeprecationIssue.Level.WARNING,
+            settings);
+    }
+
+    static DeprecationIssue checkMonitoringSettingHistoryDuration(final Settings settings, final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringSetting(settings, Setting.simpleString("xpack.monitoring.history.duration"));
+    }
+
+    static DeprecationIssue checkMonitoringSettingCollectIndexRecovery(final Settings settings, final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringSetting(settings, Setting.simpleString("xpack.monitoring.collection.index.recovery.active_only"));
+    }
+
+    static DeprecationIssue checkMonitoringSettingCollectIndices(final Settings settings, final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringSetting(settings, Setting.simpleString("xpack.monitoring.collection.indices"));
+    }
+
+    static DeprecationIssue checkMonitoringSettingCollectCcrTimeout(final Settings settings, final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringSetting(settings, Setting.simpleString("xpack.monitoring.collection.ccr.stats.timeout"));
+    }
+
+    static DeprecationIssue checkMonitoringSettingCollectEnrichStatsTimeout(final Settings settings,
+                                                                            final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringSetting(settings, Setting.simpleString("xpack.monitoring.collection.enrich.stats.timeout"));
+    }
+
+    static DeprecationIssue checkMonitoringSettingCollectIndexRecoveryStatsTimeout(final Settings settings,
+                                                                                   final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringSetting(settings, Setting.simpleString("xpack.monitoring.collection.index.recovery.timeout"));
+    }
+
+    static DeprecationIssue checkMonitoringSettingCollectIndexStatsTimeout(final Settings settings,
+                                                                           final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringSetting(settings, Setting.simpleString("xpack.monitoring.collection.index.stats.timeout"));
+    }
+
+    static DeprecationIssue checkMonitoringSettingCollectMlJobStatsTimeout(final Settings settings,
+                                                                           final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringSetting(settings, Setting.simpleString("xpack.monitoring.collection.ml.job.stats.timeout"));
+    }
+
+    static DeprecationIssue checkMonitoringSettingCollectNodeStatsTimeout(final Settings settings,
+                                                                          final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringSetting(settings, Setting.simpleString("xpack.monitoring.collection.node.stats.timeout"));
+    }
+
+    static DeprecationIssue checkMonitoringSettingCollectClusterStatsTimeout(final Settings settings,
+                                                                             final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringSetting(settings, Setting.simpleString("xpack.monitoring.collection.cluster.stats.timeout"));
+    }
+
+    static DeprecationIssue checkMonitoringSettingExportersHost(final Settings settings, final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringAffixSetting(settings, "host");
+    }
+
+    static DeprecationIssue checkMonitoringSettingExportersBulkTimeout(final Settings settings, final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringAffixSetting(settings, "bulk.timeout");
+    }
+
+    static DeprecationIssue checkMonitoringSettingExportersConnectionTimeout(final Settings settings,
+                                                                             final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringAffixSetting(settings, "connection.timeout");
+    }
+
+    static DeprecationIssue checkMonitoringSettingExportersConnectionReadTimeout(final Settings settings,
+                                                                                 final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringAffixSetting(settings, "connection.read_timeout");
+    }
+
+    static DeprecationIssue checkMonitoringSettingExportersAuthUsername(final Settings settings,
+                                                                        final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringAffixSetting(settings, "auth.username");
+    }
+
+    static DeprecationIssue checkMonitoringSettingExportersAuthPass(final Settings settings, final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringAffixSecureSetting(settings, "auth.secure_password");
+    }
+
+    static DeprecationIssue checkMonitoringSettingExportersSSL(final Settings settings, final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringAffixGroupedSetting(settings, "ssl");
+    }
+
+    static DeprecationIssue checkMonitoringSettingExportersProxyBase(final Settings settings, final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringAffixSetting(settings, "proxy.base_path");
+    }
+
+    static DeprecationIssue checkMonitoringSettingExportersSniffEnabled(final Settings settings,
+                                                                        final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringAffixSetting(settings, "sniff.enabled");
+    }
+
+    static DeprecationIssue checkMonitoringSettingExportersHeaders(final Settings settings, final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringAffixGroupedSetting(settings, "headers");
+    }
+
+    static DeprecationIssue checkMonitoringSettingExportersTemplateTimeout(final Settings settings,
+                                                                           final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringAffixSetting(settings, "index.template.master_timeout");
+    }
+
+    static DeprecationIssue checkMonitoringSettingExportersMasterTimeout(final Settings settings,
+                                                                         final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringAffixSetting(settings, "wait_master.timeout");
+    }
+
+    static DeprecationIssue checkMonitoringSettingExportersEnabled(final Settings settings, final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringAffixSetting(settings, "enabled");
+    }
+
+    static DeprecationIssue checkMonitoringSettingExportersType(final Settings settings, final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringAffixSetting(settings, "type");
+    }
+
+    static DeprecationIssue checkMonitoringSettingExportersAlertsEnabled(final Settings settings,
+                                                                         final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringAffixSetting(settings, "cluster_alerts.management.enabled");
+    }
+
+    static DeprecationIssue checkMonitoringSettingExportersAlertsBlacklist(final Settings settings,
+                                                                           final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringAffixSetting(settings, "cluster_alerts.management.blacklist");
+    }
+
+    static DeprecationIssue checkMonitoringSettingExportersIndexNameTimeFormat(final Settings settings,
+                                                                               final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringAffixSetting(settings, "index.name.time_format");
+    }
+
+    static DeprecationIssue checkMonitoringSettingDecommissionAlerts(final Settings settings, final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringSetting(settings, Setting.simpleString("xpack.monitoring.migration.decommission_alerts"));
+    }
+
+    static DeprecationIssue checkMonitoringSettingEsCollectionEnabled(final Settings settings, final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringSetting(settings, Setting.simpleString("xpack.monitoring.elasticsearch.collection.enabled"));
+    }
+
+    static DeprecationIssue checkMonitoringSettingCollectionEnabled(final Settings settings, final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringSetting(settings, Setting.simpleString("xpack.monitoring.collection.enabled"));
+    }
+
+    static DeprecationIssue checkMonitoringSettingCollectionInterval(final Settings settings, final PluginsAndModules pluginsAndModules) {
+        return genericMonitoringSetting(settings, Setting.simpleString("xpack.monitoring.collection.interval"));
+    }
+
     static DeprecationIssue checkExporterUseIngestPipelineSettings(final Settings settings, final PluginsAndModules pluginsAndModules) {
         return deprecatedAffixSetting(MonitoringDeprecatedSettings.USE_INGEST_PIPELINE_SETTING,
             "Remove the following settings from elasticsearch.yml: [%s]",

+ 157 - 0
x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java

@@ -9,6 +9,7 @@ package org.elasticsearch.xpack.deprecation;
 
 import org.elasticsearch.cluster.routing.allocation.decider.DiskThresholdDecider;
 import org.elasticsearch.common.Strings;
+import org.elasticsearch.common.settings.MockSecureSettings;
 import org.elasticsearch.common.settings.Setting;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.core.TimeValue;
@@ -140,6 +141,162 @@ public class NodeDeprecationChecksTests extends ESTestCase {
                 false, null)));
     }
 
+    void monitoringSetting(String settingKey, String value) {
+        Settings settings = Settings.builder()
+            .put(settingKey, value)
+            .build();
+        List<DeprecationIssue> issues = DeprecationChecks.filterChecks(NODE_SETTINGS_CHECKS, c -> c.apply(settings, null));
+        final String expectedUrl = "https://ela.st/es-deprecation-7-monitoring-settings";
+        assertThat(issues, hasItem(
+            new DeprecationIssue(DeprecationIssue.Level.WARNING,
+                "setting ["+settingKey+"] is deprecated and will be removed after 8.0",
+                expectedUrl,
+                "the setting ["+settingKey+"] is currently set to ["+value+"], remove this setting",
+                false, null)));
+    }
+
+    void monitoringExporterSetting(String suffix, String value) {
+        String settingKey = "xpack.monitoring.exporters.test." + suffix;
+        Settings settings = Settings.builder()
+            .put(settingKey, value)
+            .build();
+        List<DeprecationIssue> issues = DeprecationChecks.filterChecks(NODE_SETTINGS_CHECKS, c -> c.apply(settings, null));
+        final String expectedUrl = "https://ela.st/es-deprecation-7-monitoring-settings";
+        assertThat(issues, hasItem(
+            new DeprecationIssue(DeprecationIssue.Level.WARNING,
+                "The ["+settingKey+"] settings are deprecated and will be removed after 8.0",
+                expectedUrl,
+                "Remove the following settings from elasticsearch.yml: ["+settingKey+"]",
+                false, null)));
+    }
+
+    void monitoringExporterGroupedSetting(String suffix, String value) {
+        String settingKey = "xpack.monitoring.exporters.test." + suffix;
+        String subSettingKey = settingKey + ".subsetting";
+        Settings settings = Settings.builder()
+            .put(subSettingKey, value)
+            .build();
+        List<DeprecationIssue> issues = DeprecationChecks.filterChecks(NODE_SETTINGS_CHECKS, c -> c.apply(settings, null));
+        final String expectedUrl = "https://ela.st/es-deprecation-7-monitoring-settings";
+        assertThat(issues, hasItem(
+            new DeprecationIssue(DeprecationIssue.Level.WARNING,
+                "The ["+settingKey+".*] settings are deprecated and will be removed after 8.0",
+                expectedUrl,
+                "Remove the following settings from elasticsearch.yml: ["+subSettingKey+"]",
+                false, null)));
+    }
+
+    void monitoringExporterSecureSetting(String suffix, String value) {
+        String settingKey = "xpack.monitoring.exporters.test." + suffix;
+        MockSecureSettings secureSettings = new MockSecureSettings();
+        secureSettings.setString(settingKey, value);
+        Settings settings = Settings.builder()
+            .setSecureSettings(secureSettings)
+            .build();
+        List<DeprecationIssue> issues = DeprecationChecks.filterChecks(NODE_SETTINGS_CHECKS, c -> c.apply(settings, null));
+        final String expectedUrl = "https://ela.st/es-deprecation-7-monitoring-settings";
+        assertThat(issues, hasItem(
+            new DeprecationIssue(DeprecationIssue.Level.WARNING,
+                "The ["+settingKey+"] settings are deprecated and will be removed after 8.0",
+                expectedUrl,
+                "Remove the following settings from the keystore: ["+settingKey+"]",
+                false, null)));
+    }
+
+    public void testCheckMonitoringSettingHistoryDuration() {
+        monitoringSetting("xpack.monitoring.history.duration", "7d");
+    }
+    public void testCheckMonitoringSettingCollectIndexRecovery() {
+        monitoringSetting("xpack.monitoring.collection.index.recovery.active_only", "true");
+    }
+    public void testCheckMonitoringSettingCollectIndices() {
+        monitoringSetting("xpack.monitoring.collection.indices", "[test1,test2]");
+    }
+    public void testCheckMonitoringSettingCollectCcrTimeout() {
+        monitoringSetting("xpack.monitoring.collection.ccr.stats.timeout", "10s");
+    }
+    public void testCheckMonitoringSettingCollectEnrichStatsTimeout() {
+        monitoringSetting("xpack.monitoring.collection.enrich.stats.timeout", "10s");
+    }
+    public void testCheckMonitoringSettingCollectIndexRecoveryStatsTimeout() {
+        monitoringSetting("xpack.monitoring.collection.index.recovery.timeout", "10s");
+    }
+    public void testCheckMonitoringSettingCollectIndexStatsTimeout() {
+        monitoringSetting("xpack.monitoring.collection.index.stats.timeout", "10s");
+    }
+    public void testCheckMonitoringSettingCollectMlJobStatsTimeout() {
+        monitoringSetting("xpack.monitoring.collection.ml.job.stats.timeout", "10s");
+    }
+    public void testCheckMonitoringSettingCollectNodeStatsTimeout() {
+        monitoringSetting("xpack.monitoring.collection.node.stats.timeout", "10s");
+    }
+    public void testCheckMonitoringSettingCollectClusterStatsTimeout() {
+        monitoringSetting("xpack.monitoring.collection.cluster.stats.timeout", "10s");
+    }
+    public void testCheckMonitoringSettingExportersHost() {
+        monitoringExporterSetting("host", "abcdef");
+    }
+    public void testCheckMonitoringSettingExportersBulkTimeout() {
+        monitoringExporterSetting("bulk.timeout", "10s");
+    }
+    public void testCheckMonitoringSettingExportersConnectionTimeout() {
+        monitoringExporterSetting("connection.timeout", "10s");
+    }
+    public void testCheckMonitoringSettingExportersConnectionReadTimeout() {
+        monitoringExporterSetting("connection.read_timeout", "10s");
+    }
+    public void testCheckMonitoringSettingExportersAuthUsername() {
+        monitoringExporterSetting("auth.username", "abcdef");
+    }
+    public void testCheckMonitoringSettingExportersAuthPass() {
+        monitoringExporterSecureSetting("auth.secure_password", "abcdef");
+    }
+    public void testCheckMonitoringSettingExportersSSL() {
+        monitoringExporterGroupedSetting("ssl", "abcdef");
+    }
+    public void testCheckMonitoringSettingExportersProxyBase() {
+        monitoringExporterSetting("proxy.base_path", "abcdef");
+    }
+    public void testCheckMonitoringSettingExportersSniffEnabled() {
+        monitoringExporterSetting("sniff.enabled", "true");
+    }
+    public void testCheckMonitoringSettingExportersHeaders() {
+        monitoringExporterGroupedSetting("headers", "abcdef");
+    }
+    public void testCheckMonitoringSettingExportersTemplateTimeout() {
+        monitoringExporterSetting("index.template.master_timeout", "10s");
+    }
+    public void testCheckMonitoringSettingExportersMasterTimeout() {
+        monitoringExporterSetting("wait_master.timeout", "10s");
+    }
+    public void testCheckMonitoringSettingExportersEnabled() {
+        monitoringExporterSetting("enabled", "true");
+    }
+    public void testCheckMonitoringSettingExportersType() {
+        monitoringExporterSetting("type", "local");
+    }
+    public void testCheckMonitoringSettingExportersAlertsEnabled() {
+        monitoringExporterSetting("cluster_alerts.management.enabled", "true");
+    }
+    public void testCheckMonitoringSettingExportersAlertsBlacklist() {
+        monitoringExporterSetting("cluster_alerts.management.blacklist", "[abcdef,ghijkl]");
+    }
+    public void testCheckMonitoringSettingExportersIndexNameTimeFormat() {
+        monitoringExporterSetting("index.name.time_format", "yyyy-mm-dd");
+    }
+    public void testCheckMonitoringSettingDecomissionAlerts() {
+        monitoringSetting("xpack.monitoring.migration.decommission_alerts", "true");
+    }
+    public void testCheckMonitoringSettingEsCollectionEnabled() {
+        monitoringSetting("xpack.monitoring.elasticsearch.collection.enabled", "true");
+    }
+    public void testCheckMonitoringSettingCollectionEnabled() {
+        monitoringSetting("xpack.monitoring.collection.enabled", "true");
+    }
+    public void testCheckMonitoringSettingCollectionInterval() {
+        monitoringSetting("xpack.monitoring.collection.interval", "10s");
+    }
+
     public void testExporterUseIngestPipelineSettings() {
         Settings settings = Settings.builder()
             .put("xpack.monitoring.exporters.test.use_ingest", true)

+ 5 - 0
x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollectorTests.java

@@ -140,6 +140,11 @@ public class EnrichStatsCollectorTests extends BaseCollectorTestCase {
             assertThat(actual.getId(), nullValue());
             assertThat(actual.getExecutingPolicy(), equalTo(expected));
         }
+
+        assertWarnings(
+            "[xpack.monitoring.collection.enrich.stats.timeout] setting was deprecated in Elasticsearch and will be removed "
+                + "in a future release! See the breaking changes documentation for the next major version."
+        );
     }
 
     private EnrichStatsCollector createCollector(ClusterService clusterService, XPackLicenseState licenseState, Client client) {

+ 0 - 5
x-pack/plugin/ml/qa/ml-with-security/src/yamlRestTest/java/org/elasticsearch/smoketest/MlWithSecurityIT.java

@@ -54,11 +54,6 @@ public class MlWithSecurityIT extends AbstractXPackRestTest {
                 SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING));
     }
 
-    @Override
-    protected boolean isMonitoringTest() {
-        return false;
-    }
-
     @Override
     protected boolean isMachineLearningTest() {
         return true;

+ 0 - 1
x-pack/plugin/ml/qa/native-multi-node-tests/build.gradle

@@ -40,7 +40,6 @@ testClusters.configureEach {
   testDistribution = 'DEFAULT'
 
   setting 'xpack.security.enabled', 'true'
-  setting 'xpack.monitoring.elasticsearch.collection.enabled', 'false'
   setting 'xpack.ml.enabled', 'true'
   setting 'xpack.watcher.enabled', 'false'
   setting 'xpack.security.authc.token.enabled', 'true'

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

@@ -78,7 +78,7 @@ import static org.elasticsearch.common.settings.Setting.boolSetting;
 public class Monitoring extends Plugin implements ActionPlugin, ReloadablePlugin {
 
     public static final Setting<Boolean> MIGRATION_DECOMMISSION_ALERTS = boolSetting("xpack.monitoring.migration.decommission_alerts",
-        false, Setting.Property.Dynamic, Setting.Property.NodeScope);
+        false, Setting.Property.Dynamic, Setting.Property.NodeScope, Setting.Property.Deprecated);
 
     public static final LicensedFeature.Momentary MONITORING_CLUSTER_ALERTS_FEATURE =
         LicensedFeature.momentary("monitoring", "cluster-alerts", License.OperationMode.STANDARD);

+ 3 - 3
x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringService.java

@@ -59,7 +59,7 @@ public class MonitoringService extends AbstractLifecycleComponent {
       */
     public static final Setting<Boolean> ELASTICSEARCH_COLLECTION_ENABLED =
             Setting.boolSetting("xpack.monitoring.elasticsearch.collection.enabled", true,
-                                Setting.Property.Dynamic, Setting.Property.NodeScope);
+                                Setting.Property.Dynamic, Setting.Property.NodeScope, Setting.Property.Deprecated);
 
     /**
      * Dynamically controls enabling or disabling the collection of Monitoring data from Elasticsearch as well as other products
@@ -67,14 +67,14 @@ public class MonitoringService extends AbstractLifecycleComponent {
      */
     public static final Setting<Boolean> ENABLED =
             Setting.boolSetting("xpack.monitoring.collection.enabled", false,
-                                Setting.Property.Dynamic, Setting.Property.NodeScope);
+                                Setting.Property.Dynamic, Setting.Property.NodeScope, Setting.Property.Deprecated);
 
     /**
      * Sampling interval between two collections (default to 10s)
      */
     public static final Setting<TimeValue> INTERVAL =
             Setting.timeSetting("xpack.monitoring.collection.interval", TimeValue.timeValueSeconds(10), MIN_INTERVAL,
-                                Setting.Property.Dynamic, Setting.Property.NodeScope);
+                                Setting.Property.Dynamic, Setting.Property.NodeScope, Setting.Property.Deprecated);
 
     /** State of the monitoring service, either started or stopped **/
     private final AtomicBoolean started = new AtomicBoolean(false);

+ 3 - 2
x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/Collector.java

@@ -41,7 +41,8 @@ public abstract class Collector {
      * List of indices names whose stats will be exported (default to all indices)
      */
     public static final Setting<List<String>> INDICES =
-            listSetting(collectionSetting("indices"), emptyList(), Function.identity(), Property.Dynamic, Property.NodeScope);
+            listSetting(collectionSetting("indices"), emptyList(), Function.identity(), Property.Dynamic, Property.NodeScope,
+                Setting.Property.Deprecated);
 
     private final String name;
     private final Setting<TimeValue> collectionTimeoutSetting;
@@ -170,6 +171,6 @@ public abstract class Collector {
 
     protected static Setting<TimeValue> collectionTimeoutSetting(final String settingName) {
         String name = collectionSetting(settingName);
-        return timeSetting(name, TimeValue.timeValueSeconds(10), Property.Dynamic, Property.NodeScope);
+        return timeSetting(name, TimeValue.timeValueSeconds(10), Property.Dynamic, Property.NodeScope, Property.Deprecated);
     }
 }

+ 2 - 1
x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexRecoveryCollector.java

@@ -43,7 +43,8 @@ public class IndexRecoveryCollector extends Collector {
      * Flag to indicate if only active recoveries should be collected (default to false: all recoveries are collected)
      */
     public static final Setting<Boolean> INDEX_RECOVERY_ACTIVE_ONLY =
-            boolSetting(collectionSetting("index.recovery.active_only"), false, Setting.Property.Dynamic, Setting.Property.NodeScope);
+            boolSetting(collectionSetting("index.recovery.active_only"), false, Setting.Property.Dynamic, Setting.Property.NodeScope,
+                Setting.Property.Deprecated);
 
     private final Client client;
 

+ 8 - 6
x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporter.java

@@ -33,7 +33,7 @@ public abstract class Exporter implements AutoCloseable {
 
     private static final Setting.AffixSetting<Boolean> ENABLED_SETTING =
             Setting.affixKeySetting("xpack.monitoring.exporters.","enabled",
-                    key -> Setting.boolSetting(key, true, Property.Dynamic, Property.NodeScope), TYPE_DEPENDENCY);
+                    key -> Setting.boolSetting(key, true, Property.Dynamic, Property.NodeScope, Property.Deprecated), TYPE_DEPENDENCY);
 
     public static final Setting.AffixSetting<String> TYPE_SETTING = Setting.affixKeySetting(
         "xpack.monitoring.exporters.",
@@ -80,13 +80,14 @@ public abstract class Exporter implements AutoCloseable {
 
             },
             Property.Dynamic,
-            Property.NodeScope));
+            Property.NodeScope,
+            Property.Deprecated));
     /**
      * Every {@code Exporter} allows users to explicitly disable cluster alerts.
      */
     public static final Setting.AffixSetting<Boolean> CLUSTER_ALERTS_MANAGEMENT_SETTING =
             Setting.affixKeySetting("xpack.monitoring.exporters.", "cluster_alerts.management.enabled",
-                    key -> Setting.boolSetting(key, true, Property.Dynamic, Property.NodeScope), TYPE_DEPENDENCY);
+                    key -> Setting.boolSetting(key, true, Property.Dynamic, Property.NodeScope, Property.Deprecated), TYPE_DEPENDENCY);
     /**
      * Every {@code Exporter} allows users to explicitly disable specific cluster alerts.
      * <p>
@@ -94,8 +95,8 @@ public abstract class Exporter implements AutoCloseable {
      */
     public static final Setting.AffixSetting<List<String>> CLUSTER_ALERTS_BLACKLIST_SETTING = Setting
                 .affixKeySetting("xpack.monitoring.exporters.", "cluster_alerts.management.blacklist",
-                    key -> Setting.listSetting(key, Collections.emptyList(), Function.identity(), Property.Dynamic, Property.NodeScope),
-                    TYPE_DEPENDENCY);
+                    key -> Setting.listSetting(key, Collections.emptyList(), Function.identity(), Property.Dynamic, Property.NodeScope,
+                        Property.Deprecated), TYPE_DEPENDENCY);
 
     /**
      * Every {@code Exporter} allows users to use a different index time format.
@@ -107,7 +108,8 @@ public abstract class Exporter implements AutoCloseable {
                                 Exporter.INDEX_FORMAT,
                                 DateFormatter::forPattern,
                                 Property.Dynamic,
-                                Property.NodeScope), TYPE_DEPENDENCY);
+                                Property.NodeScope,
+                                Property.Deprecated), TYPE_DEPENDENCY);
 
     private static final String INDEX_FORMAT = "yyyy.MM.dd";
 

+ 19 - 11
x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporter.java

@@ -170,7 +170,8 @@ public class HttpExporter extends Exporter {
 
                     },
                     Property.Dynamic,
-                    Property.NodeScope),
+                    Property.NodeScope,
+                    Property.Deprecated),
                 HTTP_TYPE_DEPENDENCY);
 
     /**
@@ -178,7 +179,8 @@ public class HttpExporter extends Exporter {
      */
     public static final Setting.AffixSetting<TimeValue> BULK_TIMEOUT_SETTING =
             Setting.affixKeySetting("xpack.monitoring.exporters.","bulk.timeout",
-                    (key) -> Setting.timeSetting(key, TimeValue.MINUS_ONE, Property.Dynamic, Property.NodeScope), HTTP_TYPE_DEPENDENCY);
+                    (key) -> Setting.timeSetting(key, TimeValue.MINUS_ONE, Property.Dynamic, Property.NodeScope, Property.Deprecated),
+                HTTP_TYPE_DEPENDENCY);
     /**
      * Timeout used for initiating a connection.
      */
@@ -186,7 +188,7 @@ public class HttpExporter extends Exporter {
             Setting.affixKeySetting(
                 "xpack.monitoring.exporters.",
                 "connection.timeout",
-                (key) -> Setting.timeSetting(key, TimeValue.timeValueSeconds(6), Property.Dynamic, Property.NodeScope),
+                (key) -> Setting.timeSetting(key, TimeValue.timeValueSeconds(6), Property.Dynamic, Property.NodeScope, Property.Deprecated),
                 HTTP_TYPE_DEPENDENCY);
     /**
      * Timeout used for reading from the connection.
@@ -195,7 +197,8 @@ public class HttpExporter extends Exporter {
             Setting.affixKeySetting(
                 "xpack.monitoring.exporters.",
                 "connection.read_timeout",
-                (key) -> Setting.timeSetting(key, TimeValue.timeValueSeconds(60), Property.Dynamic, Property.NodeScope),
+                (key) -> Setting.timeSetting(key, TimeValue.timeValueSeconds(60), Property.Dynamic, Property.NodeScope,
+                    Property.Deprecated),
                 HTTP_TYPE_DEPENDENCY);
     /**
      * Username for basic auth.
@@ -239,7 +242,8 @@ public class HttpExporter extends Exporter {
                         },
                         Property.Dynamic,
                         Property.NodeScope,
-                        Property.Filtered),
+                        Property.Filtered,
+                        Property.Deprecated),
                 HTTP_TYPE_DEPENDENCY);
     /**
      * Secure password for basic auth.
@@ -248,7 +252,7 @@ public class HttpExporter extends Exporter {
         Setting.affixKeySetting(
             "xpack.monitoring.exporters.",
             "auth.secure_password",
-            key -> SecureSetting.secureString(key, null),
+            key -> SecureSetting.secureString(key, null, Setting.Property.Deprecated),
             HTTP_TYPE_DEPENDENCY);
     /**
      * The SSL settings.
@@ -259,7 +263,7 @@ public class HttpExporter extends Exporter {
             Setting.affixKeySetting(
                 "xpack.monitoring.exporters.",
                 "ssl",
-                (key) -> Setting.groupSetting(key + ".", Property.Dynamic, Property.NodeScope, Property.Filtered),
+                (key) -> Setting.groupSetting(key + ".", Property.Dynamic, Property.NodeScope, Property.Filtered, Property.Deprecated),
                 HTTP_TYPE_DEPENDENCY);
 
     /**
@@ -280,14 +284,16 @@ public class HttpExporter extends Exporter {
                             }
                         },
                         Property.Dynamic,
-                        Property.NodeScope),
+                        Property.NodeScope,
+                        Property.Deprecated),
                 HTTP_TYPE_DEPENDENCY);
     /**
      * A boolean setting to enable or disable sniffing for extra connections.
      */
     public static final Setting.AffixSetting<Boolean> SNIFF_ENABLED_SETTING =
             Setting.affixKeySetting("xpack.monitoring.exporters.","sniff.enabled",
-                    (key) -> Setting.boolSetting(key, false, Property.Dynamic, Property.NodeScope), HTTP_TYPE_DEPENDENCY);
+                    (key) -> Setting.boolSetting(key, false, Property.Dynamic, Property.NodeScope, Property.Deprecated),
+                HTTP_TYPE_DEPENDENCY);
     /**
      * A parent setting to header key/value pairs, whose names are user defined.
      */
@@ -309,7 +315,8 @@ public class HttpExporter extends Exporter {
                             }
                         },
                         Property.Dynamic,
-                        Property.NodeScope),
+                        Property.NodeScope,
+                        Property.Deprecated),
                 HTTP_TYPE_DEPENDENCY);
     /**
      * Blacklist of headers that the user is not allowed to set.
@@ -322,7 +329,8 @@ public class HttpExporter extends Exporter {
      */
     public static final Setting.AffixSetting<TimeValue> TEMPLATE_CHECK_TIMEOUT_SETTING =
             Setting.affixKeySetting("xpack.monitoring.exporters.","index.template.master_timeout",
-                    (key) -> Setting.timeSetting(key, TimeValue.MINUS_ONE, Property.Dynamic, Property.NodeScope), HTTP_TYPE_DEPENDENCY);
+                    (key) -> Setting.timeSetting(key, TimeValue.MINUS_ONE, Property.Dynamic, Property.NodeScope, Property.Deprecated),
+                HTTP_TYPE_DEPENDENCY);
     /**
      * Minimum supported version of the remote monitoring cluster (same major).
      */

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

@@ -91,7 +91,8 @@ public class LocalExporter extends Exporter implements ClusterStateListener, Cle
     public static final Setting.AffixSetting<TimeValue> WAIT_MASTER_TIMEOUT_SETTING = Setting.affixKeySetting(
         "xpack.monitoring.exporters.",
         "wait_master.timeout",
-        (key) -> Setting.timeSetting(key, TimeValue.timeValueSeconds(30), Property.Dynamic, Property.NodeScope), TYPE_DEPENDENCY
+        (key) -> Setting.timeSetting(key, TimeValue.timeValueSeconds(30), Property.Dynamic, Property.NodeScope, Property.Deprecated),
+        TYPE_DEPENDENCY
     );
 
     private final Client client;

+ 6 - 0
x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringHistoryDurationSettingsTests.java

@@ -20,12 +20,16 @@ public class MonitoringHistoryDurationSettingsTests extends ESTestCase {
         assertEquals(sevenDays, MonitoringField.HISTORY_DURATION.get(Settings.EMPTY));
         // Note: this verifies the semantics because this is taken for granted that it never returns null!
         assertEquals(sevenDays, MonitoringField.HISTORY_DURATION.get(buildSettings(MonitoringField.HISTORY_DURATION.getKey(), null)));
+        assertWarnings("[xpack.monitoring.history.duration] setting was deprecated in Elasticsearch and will be removed in a future " +
+            "release! See the breaking changes documentation for the next major version.");
     }
 
     public void testHistoryDurationMinimum24Hours() {
         // hit the minimum
         assertEquals(MonitoringField.HISTORY_DURATION_MINIMUM,
                 MonitoringField.HISTORY_DURATION.get(buildSettings(MonitoringField.HISTORY_DURATION.getKey(), "24h")));
+        assertWarnings("[xpack.monitoring.history.duration] setting was deprecated in Elasticsearch and will be removed in a future " +
+            "release! See the breaking changes documentation for the next major version.");
     }
 
     public void testHistoryDurationMinimum24HoursBlocksLower() {
@@ -33,6 +37,8 @@ public class MonitoringHistoryDurationSettingsTests extends ESTestCase {
         final String oneSecondEarly = (MonitoringField.HISTORY_DURATION_MINIMUM.millis() - 1) + "ms";
         expectThrows(IllegalArgumentException.class,
                 () -> MonitoringField.HISTORY_DURATION.get(buildSettings(MonitoringField.HISTORY_DURATION.getKey(), oneSecondEarly)));
+        assertWarnings("[xpack.monitoring.history.duration] setting was deprecated in Elasticsearch and will be removed in a future " +
+            "release! See the breaking changes documentation for the next major version.");
     }
 
     private Settings buildSettings(String key, String value) {

+ 8 - 0
x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringServiceTests.java

@@ -118,6 +118,8 @@ public class MonitoringServiceTests extends ESTestCase {
 
         // take down threads
         monitoringService.setMonitoringActive(false);
+        assertWarnings("[xpack.monitoring.collection.interval] setting was deprecated in Elasticsearch and will be removed in " +
+            "a future release! See the breaking changes documentation for the next major version.");
     }
 
     public void testSkipExecution() throws Exception {
@@ -141,6 +143,12 @@ public class MonitoringServiceTests extends ESTestCase {
         latch.countDown();
 
         assertThat(exporter.getExportsCount(), equalTo(1));
+        assertWarnings(
+            "[xpack.monitoring.collection.enabled] setting was deprecated in Elasticsearch and will be removed in " +
+                "a future release! See the breaking changes documentation for the next major version.",
+            "[xpack.monitoring.collection.interval] setting was deprecated in Elasticsearch and will be removed in " +
+                "a future release! See the breaking changes documentation for the next major version."
+        );
     }
 
     class CountingExporter extends Exporters {

+ 11 - 3
x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/CleanerServiceTests.java

@@ -53,10 +53,15 @@ public class CleanerServiceTests extends ESTestCase {
         // invalid setting
         expectedException.expect(IllegalArgumentException.class);
 
-        TimeValue expected = TimeValue.timeValueHours(1);
-        Settings settings = Settings.builder().put(MonitoringField.HISTORY_DURATION.getKey(), expected.getStringRep()).build();
+        try {
+            TimeValue expected = TimeValue.timeValueHours(1);
+            Settings settings = Settings.builder().put(MonitoringField.HISTORY_DURATION.getKey(), expected.getStringRep()).build();
 
-        new CleanerService(settings, clusterSettings, threadPool, licenseState);
+            new CleanerService(settings, clusterSettings, threadPool, licenseState);
+        } finally {
+            assertWarnings("[xpack.monitoring.history.duration] setting was deprecated in Elasticsearch and will be removed in " +
+                "a future release! See the breaking changes documentation for the next major version.");
+        }
     }
 
     public void testGetRetention() {
@@ -64,6 +69,9 @@ public class CleanerServiceTests extends ESTestCase {
         Settings settings = Settings.builder().put(MonitoringField.HISTORY_DURATION.getKey(), expected.getStringRep()).build();
 
         assertEquals(expected, new CleanerService(settings, clusterSettings, threadPool, licenseState).getRetention());
+
+        assertWarnings("[xpack.monitoring.history.duration] setting was deprecated in Elasticsearch and will be removed in " +
+            "a future release! See the breaking changes documentation for the next major version.");
     }
 
     public void testSetGlobalRetention() {

+ 9 - 0
x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollectorTests.java

@@ -269,6 +269,9 @@ public class ClusterStatsCollectorTests extends BaseCollectorTestCase {
         verify(licenseService, times(1)).getLicense();
         verify(clusterAdminClient).prepareClusterStats();
         verify(client).execute(same(XPackUsageAction.INSTANCE), any(XPackUsageRequest.class));
+
+        assertWarnings("[xpack.monitoring.collection.cluster.stats.timeout] setting was deprecated in Elasticsearch and will be removed " +
+            "in a future release! See the breaking changes documentation for the next major version.");
     }
 
     public void testDoCollectNoLicense() throws Exception {
@@ -330,6 +333,9 @@ public class ClusterStatsCollectorTests extends BaseCollectorTestCase {
         assertEquals(1, results.size());
         final ClusterStatsMonitoringDoc doc = (ClusterStatsMonitoringDoc) results.iterator().next();
         assertThat(doc.getLicense(), nullValue());
+
+        assertWarnings("[xpack.monitoring.collection.cluster.stats.timeout] setting was deprecated in Elasticsearch and will be removed " +
+            "in a future release! See the breaking changes documentation for the next major version.");
     }
 
     public void testDoCollectThrowsTimeoutException() throws Exception {
@@ -383,6 +389,9 @@ public class ClusterStatsCollectorTests extends BaseCollectorTestCase {
                 new ClusterStatsCollector(settings.build(), clusterService, licenseState,
                         client, licenseService, indexNameExpressionResolver);
         expectThrows(ElasticsearchTimeoutException.class, () -> collector.doCollect(node, interval, clusterState));
+
+        assertWarnings("[xpack.monitoring.collection.cluster.stats.timeout] setting was deprecated in Elasticsearch and will be removed " +
+            "in a future release! See the breaking changes documentation for the next major version.");
     }
 
 }

+ 11 - 0
x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexRecoveryCollectorTests.java

@@ -169,6 +169,14 @@ public class IndexRecoveryCollectorTests extends BaseCollectorTestCase {
             assertThat(recoveries.hasRecoveries(), equalTo(true));
             assertThat(recoveries.shardRecoveryStates().size(), equalTo(nbRecoveries));
         }
+
+        assertWarnings("[xpack.monitoring.collection.index.recovery.timeout] setting was deprecated in Elasticsearch and will be " +
+            "removed in a future release! See the breaking changes documentation for the next major version.",
+            "[xpack.monitoring.collection.index.recovery.active_only] setting was deprecated in Elasticsearch and will be removed " +
+                "in a future release! See the breaking changes documentation for the next major version.",
+            "[xpack.monitoring.collection.indices] setting was deprecated in Elasticsearch and will be removed in a future release! " +
+                "See the breaking changes documentation for the next major version."
+        );
     }
 
     public void testDoCollectThrowsTimeoutException() throws Exception {
@@ -211,6 +219,9 @@ public class IndexRecoveryCollectorTests extends BaseCollectorTestCase {
         final long interval = randomNonNegativeLong();
 
         expectThrows(ElasticsearchTimeoutException.class, () -> collector.doCollect(node, interval, clusterState));
+
+        assertWarnings("[xpack.monitoring.collection.index.recovery.timeout] setting was deprecated in Elasticsearch and will be " +
+                "removed in a future release! See the breaking changes documentation for the next major version.");
     }
 
 }

+ 6 - 0
x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexStatsCollectorTests.java

@@ -170,6 +170,9 @@ public class IndexStatsCollectorTests extends BaseCollectorTestCase {
                 assertThat(indexStatsDocument.getIndexRoutingTable(), is(indicesRoutingTable.get(index)));
             }
         }
+
+        assertWarnings("[xpack.monitoring.collection.index.stats.timeout] setting was deprecated in Elasticsearch and will be removed " +
+            "in a future release! See the breaking changes documentation for the next major version.");
     }
 
     public void testDoCollectThrowsTimeoutException() throws Exception {
@@ -203,6 +206,9 @@ public class IndexStatsCollectorTests extends BaseCollectorTestCase {
         final long interval = randomNonNegativeLong();
 
         expectThrows(ElasticsearchTimeoutException.class, () -> collector.doCollect(node, interval, clusterState));
+
+        assertWarnings("[xpack.monitoring.collection.index.stats.timeout] setting was deprecated in Elasticsearch and will be removed " +
+            "in a future release! See the breaking changes documentation for the next major version.");
     }
 
 }

+ 6 - 0
x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/ml/JobStatsCollectorTests.java

@@ -141,6 +141,9 @@ public class JobStatsCollectorTests extends BaseCollectorTestCase {
 
             assertThat(jobStatsMonitoringDoc.getJobStats(), is(jobStat));
         }
+
+        assertWarnings("[xpack.monitoring.collection.ml.job.stats.timeout] setting was deprecated in Elasticsearch and will be removed " +
+            "in a future release! See the breaking changes documentation for the next major version.");
     }
 
     public void testDoCollectThrowsTimeoutException() throws Exception {
@@ -170,6 +173,9 @@ public class JobStatsCollectorTests extends BaseCollectorTestCase {
         final long interval = randomNonNegativeLong();
 
         expectThrows(ElasticsearchTimeoutException.class, () -> collector.doCollect(node, interval, clusterState));
+
+        assertWarnings("[xpack.monitoring.collection.ml.job.stats.timeout] setting was deprecated in Elasticsearch and will be removed " +
+            "in a future release! See the breaking changes documentation for the next major version.");
     }
 
     private List<JobStats> mockJobStats() {

+ 9 - 0
x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsCollectorTests.java

@@ -65,6 +65,9 @@ public class NodeStatsCollectorTests extends BaseCollectorTestCase {
         final FailedNodeException e = expectThrows(FailedNodeException.class, () ->
                 collector.doCollect(randomMonitoringNode(random()), randomNonNegativeLong(), clusterState));
         assertEquals(exception, e);
+
+        assertWarnings("[xpack.monitoring.collection.node.stats.timeout] setting was deprecated in Elasticsearch and will be removed " +
+            "in a future release! See the breaking changes documentation for the next major version.");
     }
 
     public void testDoCollect() throws Exception {
@@ -118,6 +121,9 @@ public class NodeStatsCollectorTests extends BaseCollectorTestCase {
         assertThat(document.getNodeId(), equalTo(node.getUUID()));
         assertThat(document.getNodeStats(), is(nodeStats));
         assertThat(document.isMlockall(), equalTo(BootstrapInfo.isMemoryLocked()));
+
+        assertWarnings("[xpack.monitoring.collection.node.stats.timeout] setting was deprecated in Elasticsearch and will be removed " +
+            "in a future release! See the breaking changes documentation for the next major version.");
     }
 
     public void testDoCollectThrowsTimeout() throws Exception {
@@ -146,6 +152,9 @@ public class NodeStatsCollectorTests extends BaseCollectorTestCase {
         final long interval = randomNonNegativeLong();
 
         expectThrows(ElasticsearchTimeoutException.class, () -> collector.doCollect(node, interval, clusterState));
+
+        assertWarnings("[xpack.monitoring.collection.node.stats.timeout] setting was deprecated in Elasticsearch and will be removed " +
+            "in a future release! See the breaking changes documentation for the next major version.");
     }
 
     private void thenReturnNodeStats(final Client client, final TimeValue timeout, final NodesStatsResponse nodesStatsResponse) {

+ 3 - 0
x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/shards/ShardsCollectorTests.java

@@ -121,6 +121,9 @@ public class ShardsCollectorTests extends BaseCollectorTestCase {
             }
 
         }
+
+        assertWarnings("[xpack.monitoring.collection.indices] setting was deprecated in Elasticsearch and will be removed in a" +
+            " future release! See the breaking changes documentation for the next major version.");
     }
 
     private static RoutingTable mockRoutingTable() {

+ 6 - 0
x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/ClusterAlertsUtilTests.java

@@ -108,12 +108,18 @@ public class ClusterAlertsUtilTests extends ESTestCase {
         assertThat(exception.getMessage(),
                    equalTo("[xpack.monitoring.exporters._random.cluster_alerts.management.blacklist] contains unrecognized Cluster " +
                            "Alert IDs [" + unknownIdsString + "]"));
+
+        assertWarnings("[xpack.monitoring.exporters._random.cluster_alerts.management.blacklist] setting was deprecated in " +
+            "Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.");
     }
 
     public void testGetClusterAlertsBlacklist() {
         final List<String> blacklist = randomSubsetOf(Arrays.asList(ClusterAlertsUtil.WATCH_IDS));
 
         assertThat(blacklist, equalTo(ClusterAlertsUtil.getClusterAlertsBlacklist(createConfigWithBlacklist("any", blacklist))));
+
+        assertWarnings("[xpack.monitoring.exporters.any.cluster_alerts.management.blacklist] setting was deprecated in Elasticsearch " +
+            "and will be removed in a future release! See the breaking changes documentation for the next major version.");
     }
 
     private Exporter.Config createConfigWithBlacklist(final String name, final List<String> blacklist) {

+ 21 - 0
x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/ExportersTests.java

@@ -117,6 +117,8 @@ public class ExportersTests extends ESTestCase {
         assertThat(e, hasToString(containsString("Failed to parse value [http] for setting [" + prefix + ".type]")));
         assertThat(e.getCause(), instanceOf(SettingsException.class));
         assertThat(e.getCause(), hasToString(containsString("host list for [" + prefix + ".host] is empty")));
+        assertWarnings("[xpack.monitoring.exporters.example.type] setting was deprecated in Elasticsearch and will be removed in a " +
+            "future release! See the breaking changes documentation for the next major version.");
     }
 
     public void testIndexNameTimeFormatMustBeValid() {
@@ -130,6 +132,8 @@ public class ExportersTests extends ESTestCase {
         assertThat(e, hasToString(containsString("Invalid format: [" + value + "]: Unknown pattern letter: j")));
         assertThat(e.getCause(), instanceOf(IllegalArgumentException.class));
         assertThat(e.getCause(), hasToString(containsString("Unknown pattern letter: j")));
+        assertWarnings("[xpack.monitoring.exporters.example.index.name.time_format] setting was deprecated in Elasticsearch and will " +
+            "be removed in a future release! See the breaking changes documentation for the next major version.");
     }
 
     public void testExporterIndexPattern() {
@@ -181,6 +185,9 @@ public class ExportersTests extends ESTestCase {
 
         // the only configured exporter is disabled... yet we intentionally don't fallback on the default
         assertThat(internalExporters.size(), is(0));
+
+        assertWarnings("[xpack.monitoring.exporters._name.enabled] setting was deprecated in Elasticsearch and will be removed in a " +
+            "future release! See the breaking changes documentation for the next major version.");
     }
 
     public void testInitExportersSingleUnknownType() throws Exception {
@@ -265,6 +272,17 @@ public class ExportersTests extends ESTestCase {
         assertEquals(settings.get("xpack.monitoring.exporters._name0.cluster_alerts.management.blacklist"), "true");
         assertEquals(settings.get("xpack.monitoring.exporters._name1.type"), "http");
         assertEquals(settings.get("xpack.monitoring.exporters._name1.cluster_alerts.management.blacklist"), "false");
+
+        assertWarnings(
+            "[xpack.monitoring.exporters._name1.type] setting was deprecated in Elasticsearch and will be removed in a future release! " +
+                "See the breaking changes documentation for the next major version.",
+            "[xpack.monitoring.exporters._name0.type] setting was deprecated in Elasticsearch and will be removed in a future release! " +
+                "See the breaking changes documentation for the next major version.",
+            "[xpack.monitoring.exporters._name0.cluster_alerts.management.blacklist] setting was deprecated in Elasticsearch and will " +
+                "be removed in a future release! See the breaking changes documentation for the next major version.",
+            "[xpack.monitoring.exporters._name1.cluster_alerts.management.blacklist] setting was deprecated in Elasticsearch and will " +
+                "be removed in a future release! See the breaking changes documentation for the next major version."
+        );
     }
 
     public void testExporterBlocksOnClusterState() {
@@ -311,6 +329,9 @@ public class ExportersTests extends ESTestCase {
         assertExporters(exporters);
 
         exporters.close();
+
+        assertWarnings("[xpack.monitoring.exporters.explicitly_disabled.enabled] setting was deprecated in Elasticsearch and will be " +
+            "removed in a future release! See the breaking changes documentation for the next major version.");
     }
 
     /**

+ 3 - 0
x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterResourceTests.java

@@ -362,6 +362,9 @@ public class HttpExporterResourceTests extends AbstractPublishableHttpResourceTe
         verifyPutWatches(0);
         verifyDeleteWatches(EXPECTED_WATCHES);
         verifyNoMoreInteractions(client);
+
+        assertWarnings("[xpack.monitoring.migration.decommission_alerts] setting was deprecated in Elasticsearch and will be " +
+            "removed in a future release! See the breaking changes documentation for the next major version.");
     }
 
     public void testSuccessfulChecksOnElectedMasterNode() {

+ 90 - 0
x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterTests.java

@@ -100,8 +100,11 @@ public class HttpExporterTests extends ESTestCase {
     private void runTestEmptyHostList(final boolean useDefault) {
         final String prefix = "xpack.monitoring.exporters.example";
         final Settings.Builder builder = Settings.builder().put(prefix + ".type", "http");
+        List<String> expectedWarnings = new ArrayList<>();
         if (useDefault == false) {
             builder.putList(prefix + ".host", Collections.emptyList());
+            expectedWarnings.add("[xpack.monitoring.exporters.example.host] setting was deprecated in Elasticsearch and will be removed " +
+                "in a future release! See the breaking changes documentation for the next major version.");
         }
         final Settings settings = builder.build();
         final IllegalArgumentException e = expectThrows(
@@ -110,6 +113,9 @@ public class HttpExporterTests extends ESTestCase {
         assertThat(e, hasToString(containsString("Failed to parse value [[]] for setting [" + prefix + ".host]")));
         assertThat(e.getCause(), instanceOf(SettingsException.class));
         assertThat(e.getCause(), hasToString(containsString("host list for [" + prefix + ".host] is empty")));
+        expectedWarnings.add("[xpack.monitoring.exporters.example.type] setting was deprecated in Elasticsearch and will be removed " +
+            "in a future release! See the breaking changes documentation for the next major version.");
+        assertWarnings(expectedWarnings.toArray(new String[0]));
     }
 
     public void testEmptyHostListOkayIfTypeNotSetDefault() {
@@ -129,6 +135,8 @@ public class HttpExporterTests extends ESTestCase {
         builder.putList(prefix + ".host", Collections.emptyList());
         final Settings settings = builder.build();
         HttpExporter.HOST_SETTING.getConcreteSetting(prefix + ".host").get(settings);
+        assertWarnings("[xpack.monitoring.exporters.example.host] setting was deprecated in Elasticsearch and will be removed in a " +
+            "future release! See the breaking changes documentation for the next major version.");
     }
 
     public void testHostListIsRejectedIfTypeIsNotHttp() {
@@ -139,6 +147,12 @@ public class HttpExporterTests extends ESTestCase {
         final ClusterSettings clusterSettings = new ClusterSettings(settings, Set.of(HttpExporter.HOST_SETTING, Exporter.TYPE_SETTING));
         final SettingsException e = expectThrows(SettingsException.class, () -> clusterSettings.validate(settings, true));
         assertThat(e, hasToString(containsString("[" + prefix + ".host] is set but type is [local]")));
+        assertWarnings(
+            "[xpack.monitoring.exporters.example.type] setting was deprecated in Elasticsearch and will be removed in a future release! " +
+                "See the breaking changes documentation for the next major version.",
+            "[xpack.monitoring.exporters.example.host] setting was deprecated in Elasticsearch and will be removed in a future release! " +
+                "See the breaking changes documentation for the next major version."
+        );
     }
 
     public void testSecurePasswordIsRejectedIfTypeIsNotHttp() {
@@ -157,6 +171,12 @@ public class HttpExporterTests extends ESTestCase {
             new ClusterSettings(settings, Set.of(HttpExporter.AUTH_SECURE_PASSWORD_SETTING, Exporter.TYPE_SETTING));
         final SettingsException e = expectThrows(SettingsException.class, () -> clusterSettings.validate(settings, true));
         assertThat(e, hasToString(containsString("[" + prefix + settingName + "] is set but type is [local]")));
+        assertWarnings(
+            "[xpack.monitoring.exporters.example.type] setting was deprecated in Elasticsearch and will be removed in a future release! " +
+                "See the breaking changes documentation for the next major version.",
+            "[xpack.monitoring.exporters.example.auth.secure_password] setting was deprecated in Elasticsearch and will be removed in a " +
+                "future release! See the breaking changes documentation for the next major version."
+        );
     }
 
     public void testInvalidHost() {
@@ -176,6 +196,12 @@ public class HttpExporterTests extends ESTestCase {
         assertThat(e.getCause(), hasToString(containsString("[" + prefix + ".host] invalid host: [" + host + "]")));
         assertThat(e.getCause().getCause(), instanceOf(IllegalArgumentException.class));
         assertThat(e.getCause().getCause(), hasToString(containsString("HttpHosts do not use paths [/].")));
+        assertWarnings(
+            "[xpack.monitoring.exporters.example.host] setting was deprecated in Elasticsearch and will be removed in a future release! " +
+                "See the breaking changes documentation for the next major version.",
+            "[xpack.monitoring.exporters.example.type] setting was deprecated in Elasticsearch and will be removed in a future release! " +
+                "See the breaking changes documentation for the next major version."
+        );
     }
 
     public void testMixedSchemes() {
@@ -195,6 +221,12 @@ public class HttpExporterTests extends ESTestCase {
                 "Failed to parse value [[\"" + httpHost + "\",\"" + httpsHost + "\"]] for setting [" + prefix + ".host]")));
         assertThat(e.getCause(), instanceOf(SettingsException.class));
         assertThat(e.getCause(), hasToString(containsString("[" + prefix + ".host] must use a consistent scheme: http or https")));
+        assertWarnings(
+            "[xpack.monitoring.exporters.example.host] setting was deprecated in Elasticsearch and will be removed in a future release! " +
+                "See the breaking changes documentation for the next major version.",
+            "[xpack.monitoring.exporters.example.type] setting was deprecated in Elasticsearch and will be removed in a future release! " +
+                "See the breaking changes documentation for the next major version."
+        );
     }
 
     public void testExporterWithBlacklistedHeaders() {
@@ -217,6 +249,13 @@ public class HttpExporterTests extends ESTestCase {
                 expectThrows(SettingsException.class, () -> new HttpExporter(config, sslService, threadContext, coordinator));
 
         assertThat(exception.getMessage(), equalTo(expected));
+
+        assertWarnings(
+            "[xpack.monitoring.exporters._http.host] setting was deprecated in Elasticsearch and will be removed in a " +
+                "future release! See the breaking changes documentation for the next major version.",
+            "[xpack.monitoring.exporters._http.type] setting was deprecated in Elasticsearch and will be removed in a future release! " +
+                "See the breaking changes documentation for the next major version."
+        );
     }
 
     public void testExporterWithEmptyHeaders() {
@@ -238,6 +277,12 @@ public class HttpExporterTests extends ESTestCase {
                 expectThrows(SettingsException.class, () -> new HttpExporter(config, sslService, threadContext, coordinator));
 
         assertThat(exception.getMessage(), equalTo(expected));
+        assertWarnings(
+            "[xpack.monitoring.exporters._http.host] setting was deprecated in Elasticsearch and will be removed in a future release! " +
+                "See the breaking changes documentation for the next major version.",
+            "[xpack.monitoring.exporters._http.type] setting was deprecated in Elasticsearch and will be removed in a future release! " +
+                "See the breaking changes documentation for the next major version."
+        );
     }
 
     public void testExporterWithUnknownBlacklistedClusterAlerts() {
@@ -267,6 +312,8 @@ public class HttpExporterTests extends ESTestCase {
         assertThat(exception.getMessage(),
                    equalTo("[xpack.monitoring.exporters._http.cluster_alerts.management.blacklist] contains unrecognized Cluster " +
                            "Alert IDs [does_not_exist]"));
+        assertWarnings("[xpack.monitoring.exporters._http.cluster_alerts.management.blacklist] setting was deprecated in Elasticsearch" +
+            " and will be removed in a future release! See the breaking changes documentation for the next major version.");
     }
 
     public void testExporterWithHostOnly() throws Exception {
@@ -281,6 +328,12 @@ public class HttpExporterTests extends ESTestCase {
         final MonitoringMigrationCoordinator coordinator = new MonitoringMigrationCoordinator();
 
         new HttpExporter(config, sslService, threadContext, coordinator).close();
+        assertWarnings(
+            "[xpack.monitoring.exporters._http.host] setting was deprecated in Elasticsearch and will be removed in a future release! " +
+                "See the breaking changes documentation for the next major version.",
+            "[xpack.monitoring.exporters._http.type] setting was deprecated in Elasticsearch and will be removed in a future release! " +
+                "See the breaking changes documentation for the next major version."
+        );
     }
 
     public void testExporterWithInvalidProxyBasePath() throws Exception {
@@ -304,16 +357,23 @@ public class HttpExporterTests extends ESTestCase {
 
         assertThat(e.getCause(), instanceOf(SettingsException.class));
         assertThat(e.getCause(), hasToString(containsString(expected)));
+        assertWarnings("[xpack.monitoring.exporters._http.proxy.base_path] setting was deprecated in Elasticsearch and will be removed " +
+            "in a future release! See the breaking changes documentation for the next major version.");
     }
 
     public void testCreateRestClient() throws IOException {
         final SSLIOSessionStrategy sslStrategy = mock(SSLIOSessionStrategy.class);
 
         when(sslService.sslIOSessionStrategy(any(Settings.class))).thenReturn(sslStrategy);
+        List<String> expectedWarnings = new ArrayList<>();
 
         final Settings.Builder builder = Settings.builder()
                 .put("xpack.monitoring.exporters._http.type", "http")
                 .put("xpack.monitoring.exporters._http.host", "http://localhost:9200");
+        expectedWarnings.add("[xpack.monitoring.exporters._http.host] setting was deprecated in Elasticsearch and will be removed in " +
+            "a future release! See the breaking changes documentation for the next major version.");
+        expectedWarnings.add("[xpack.monitoring.exporters._http.type] setting was deprecated in Elasticsearch and will be removed in " +
+            "a future release! See the breaking changes documentation for the next major version.");
 
         // use basic auth
         final boolean useBasicAuth = randomBoolean();
@@ -322,6 +382,8 @@ public class HttpExporterTests extends ESTestCase {
             MockSecureSettings mockSecureSettings  = new MockSecureSettings();
             mockSecureSettings.setString("xpack.monitoring.exporters._http.auth.secure_password", "securePassword");
             builder.setSecureSettings(mockSecureSettings);
+            expectedWarnings.add("[xpack.monitoring.exporters._http.auth.username] setting was deprecated in Elasticsearch and will be " +
+                "removed in a future release! See the breaking changes documentation for the next major version.");
         }
 
         // use headers
@@ -334,6 +396,10 @@ public class HttpExporterTests extends ESTestCase {
 
         // doesn't explode
         HttpExporter.createRestClient(config, sslService, listener).close();
+
+        if (expectedWarnings.size() > 0) {
+            assertWarnings(expectedWarnings.toArray(new String[0]));
+        }
     }
 
     public void testCreateCredentialsProviderWithoutSecurity() {
@@ -345,6 +411,9 @@ public class HttpExporterTests extends ESTestCase {
         CredentialsProvider provider = HttpExporter.createCredentialsProvider(config);
 
         assertNull(provider);
+
+        assertWarnings("[xpack.monitoring.exporters._http.type] setting was deprecated in Elasticsearch and will be removed in a " +
+            "future release! See the breaking changes documentation for the next major version.");
     }
 
     public void testCreateSnifferDisabledByDefault() {
@@ -383,6 +452,15 @@ public class HttpExporterTests extends ESTestCase {
         verify(client, atMost(1)).performRequest(any(Request.class));
 
         verifyNoMoreInteractions(client, listener);
+
+        assertWarnings(
+            "[xpack.monitoring.exporters._http.sniff.enabled] setting was deprecated in Elasticsearch and will be removed " +
+                "in a future release! See the breaking changes documentation for the next major version.",
+            "[xpack.monitoring.exporters._http.host] setting was deprecated in Elasticsearch and will be removed in a future release!" +
+                " See the breaking changes documentation for the next major version.",
+            "[xpack.monitoring.exporters._http.type] setting was deprecated in Elasticsearch and will be removed in a future release!" +
+                " See the breaking changes documentation for the next major version."
+        );
     }
 
     public void testCreateResources() {
@@ -391,13 +469,20 @@ public class HttpExporterTests extends ESTestCase {
 
         final Settings.Builder builder = Settings.builder()
                 .put("xpack.monitoring.exporters._http.type", "http");
+        List<String> warningsExpected = new ArrayList<>();
 
         if (clusterAlertManagement == false) {
             builder.put("xpack.monitoring.exporters._http.cluster_alerts.management.enabled", false);
+            warningsExpected.add("[xpack.monitoring.exporters._http.cluster_alerts.management.enabled] setting was deprecated in " +
+                "Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major " +
+                "version.");
         }
 
         if (templateTimeout != null) {
             builder.put("xpack.monitoring.exporters._http.index.template.master_timeout", templateTimeout.getStringRep());
+            warningsExpected.add("[xpack.monitoring.exporters._http.index.template.master_timeout] setting was deprecated in " +
+                "Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major " +
+                "version.");
         }
 
         final Config config = createConfig(builder.build());
@@ -441,6 +526,9 @@ public class HttpExporterTests extends ESTestCase {
 
         assertThat(uniqueOwners, hasSize(1));
         assertThat(uniqueOwners.get(0), equalTo("xpack.monitoring.exporters._http"));
+        if (warningsExpected.size() > 0) {
+            assertWarnings(warningsExpected.toArray(new String[0]));
+        }
     }
 
     public void testCreateDefaultParams() {
@@ -461,6 +549,8 @@ public class HttpExporterTests extends ESTestCase {
 
         if (bulkTimeout != null) {
             assertThat(parameters.remove("timeout"), equalTo(bulkTimeout.toString()));
+            assertWarnings("[xpack.monitoring.exporters._http.bulk.timeout] setting was deprecated in Elasticsearch and will be removed " +
+                "in a future release! See the breaking changes documentation for the next major version.");
         } else {
             assertNull(parameters.remove("timeout"));
         }

+ 0 - 105
x-pack/plugin/src/test/java/org/elasticsearch/xpack/test/rest/AbstractXPackRestTest.java

@@ -11,10 +11,8 @@ import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
 
 import org.apache.http.HttpStatus;
 import org.apache.lucene.util.TimeUnits;
-import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.util.concurrent.ThreadContext;
-import org.elasticsearch.common.xcontent.support.XContentMapValues;
 import org.elasticsearch.core.CheckedFunction;
 import org.elasticsearch.plugins.MetadataUpgrader;
 import org.elasticsearch.test.SecuritySettingsSourceField;
@@ -32,20 +30,13 @@ import org.junit.Before;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.function.Supplier;
 
 import static java.util.Collections.emptyList;
-import static java.util.Collections.emptyMap;
-import static java.util.Collections.singletonList;
 import static java.util.Collections.singletonMap;
-import static org.elasticsearch.common.xcontent.support.XContentMapValues.extractValue;
-import static org.elasticsearch.rest.action.search.RestSearchAction.TOTAL_HITS_AS_INT_PARAM;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.hasSize;
 
 /** Runs rest tests against external cluster */
 // TODO: Remove this timeout increase once this test suite is broken up
@@ -74,7 +65,6 @@ public class AbstractXPackRestTest extends ESClientYamlSuiteTestCase {
     @Before
     public void setupForTests() throws Exception {
         waitForTemplates();
-        enableMonitoring();
     }
 
     /**
@@ -96,95 +86,6 @@ public class AbstractXPackRestTest extends ESClientYamlSuiteTestCase {
         }
     }
 
-    /**
-     * Enable monitoring and waits for monitoring documents to be collected and indexed in
-     * monitoring indices.This is the signal that the local exporter is started and ready
-     * for the tests.
-     */
-    private void enableMonitoring() throws Exception {
-        if (isMonitoringTest()) {
-            final ClientYamlTestResponse xpackUsage =
-                    callApi("xpack.usage", singletonMap("filter_path", "monitoring.enabled_exporters"), emptyList(), getApiCallHeaders());
-
-            @SuppressWarnings("unchecked")
-            final Map<String, Object> exporters = (Map<String, Object>) xpackUsage.evaluate("monitoring.enabled_exporters");
-            assertNotNull("List of monitoring exporters must not be null", exporters);
-            assertThat("List of enabled exporters must be empty before enabling monitoring",
-                    XContentMapValues.extractRawValues("monitoring.enabled_exporters", exporters), hasSize(0));
-
-            final Map<String, Object> settings = new HashMap<>();
-            settings.put("xpack.monitoring.collection.enabled", true);
-            settings.put("xpack.monitoring.collection.interval", "1s");
-            settings.put("xpack.monitoring.exporters._local.type", "local");
-            settings.put("xpack.monitoring.exporters._local.enabled", true);
-
-            awaitCallApi("cluster.put_settings", emptyMap(),
-                    singletonList(singletonMap("persistent", settings)),
-                    response -> {
-                        Object acknowledged = response.evaluate("acknowledged");
-                        return acknowledged != null && (Boolean) acknowledged;
-                    },
-                    () -> "Exception when enabling monitoring");
-            Map<String, String> searchParams = new HashMap<>();
-            searchParams.put("index", ".monitoring-*");
-            searchParams.put(TOTAL_HITS_AS_INT_PARAM, "true");
-            awaitCallApi("search", searchParams, emptyList(),
-                    response -> ((Number) response.evaluate("hits.total")).intValue() > 0,
-                    () -> "Exception when waiting for monitoring documents to be indexed");
-        }
-    }
-
-    /**
-     * Disable monitoring
-     */
-    private void disableMonitoring() throws Exception {
-        if (isMonitoringTest()) {
-            final Map<String, Object> settings = new HashMap<>();
-            settings.put("xpack.monitoring.collection.enabled", null);
-            settings.put("xpack.monitoring.collection.interval", null);
-            settings.put("xpack.monitoring.exporters._local.enabled", null);
-
-            awaitCallApi("cluster.put_settings", emptyMap(),
-                    singletonList(singletonMap("persistent", settings)),
-                    response -> {
-                        Object acknowledged = response.evaluate("acknowledged");
-                        return acknowledged != null && (Boolean) acknowledged;
-                    },
-                    () -> "Exception when disabling monitoring");
-
-            assertBusy(() -> {
-                try {
-                    ClientYamlTestResponse response =
-                            callApi("xpack.usage", singletonMap("filter_path", "monitoring.enabled_exporters"), emptyList(),
-                                    getApiCallHeaders());
-
-                    @SuppressWarnings("unchecked")
-                    final Map<String, ?> exporters = (Map<String, ?>) response.evaluate("monitoring.enabled_exporters");
-                    if (exporters.isEmpty() == false) {
-                        fail("Exporters were not found");
-                    }
-
-                    final Map<String, String> params = new HashMap<>();
-                    params.put("node_id", "_local");
-                    params.put("metric", "thread_pool");
-                    params.put("filter_path", "nodes.*.thread_pool.write.active");
-                    response = callApi("nodes.stats", params, emptyList(), getApiCallHeaders());
-
-                    @SuppressWarnings("unchecked")
-                    final Map<String, Object> nodes = (Map<String, Object>) response.evaluate("nodes");
-                    @SuppressWarnings("unchecked")
-                    final Map<String, Object> node = (Map<String, Object>) nodes.values().iterator().next();
-
-                    final Number activeWrites = (Number) extractValue("thread_pool.write.active", node);
-                    assertNotNull(activeWrites);
-                    assertThat(activeWrites, equalTo(0));
-                } catch (Exception e) {
-                    throw new ElasticsearchException("Failed to wait for monitoring exporters to stop:", e);
-                }
-            });
-        }
-    }
-
     /**
      * Cleanup after tests.
      *
@@ -193,7 +94,6 @@ public class AbstractXPackRestTest extends ESClientYamlSuiteTestCase {
      */
     @After
     public void cleanup() throws Exception {
-        disableMonitoring();
         clearMlState();
         if (isWaitForPendingTasks()) {
             // This waits for pending tasks to complete, so must go last (otherwise
@@ -251,11 +151,6 @@ public class AbstractXPackRestTest extends ESClientYamlSuiteTestCase {
         return true;
     }
 
-    protected boolean isMonitoringTest() {
-        String testName = getTestName();
-        return testName != null && (testName.contains("=monitoring/") || testName.contains("=monitoring\\"));
-    }
-
     protected boolean isMachineLearningTest() {
         String testName = getTestName();
         return testName != null && (testName.contains("=ml/") || testName.contains("=ml\\"));

+ 0 - 5
x-pack/plugin/text-structure/qa/text-structure-with-security/src/yamlRestTest/java/org/elasticsearch/smoketest/TextStructureWithSecurityIT.java

@@ -51,9 +51,4 @@ public class TextStructureWithSecurityIT extends AbstractXPackRestTest {
         );
     }
 
-    @Override
-    protected boolean isMonitoringTest() {
-        return false;
-    }
-
 }

+ 0 - 18
x-pack/plugin/watcher/qa/with-monitoring/src/javaRestTest/java/org/elasticsearch/smoketest/MonitoringWithWatcherRestIT.java

@@ -61,24 +61,6 @@ public class MonitoringWithWatcherRestIT extends ESRestTestCase {
         assertMonitoringWatchHasBeenOverWritten(watchId);
     }
 
-    public void testThatHttpExporterAddsWatches() throws Exception {
-        String watchId = createMonitoringWatch();
-        String httpHost = getHttpHost();
-
-        Request request = new Request("PUT", "/_cluster/settings");
-        request.setJsonEntity(Strings.toString(jsonBuilder().startObject()
-                .startObject("persistent")
-                    .field("xpack.monitoring.exporters.my_http_exporter.type", "http")
-                    .field("xpack.monitoring.exporters.my_http_exporter.host", httpHost)
-                    .field("xpack.monitoring.exporters.my_http_exporter.cluster_alerts.management.enabled", true)
-                .endObject().endObject()));
-        adminClient().performRequest(request);
-
-        assertTotalWatchCount(WATCH_IDS.length);
-
-        assertMonitoringWatchHasBeenOverWritten(watchId);
-    }
-
     private void assertMonitoringWatchHasBeenOverWritten(String watchId) throws Exception {
         assertBusy(() -> {
             ObjectPath path = ObjectPath.createFromResponse(client().performRequest(new Request("GET", "/_watcher/watch/" + watchId)));