-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Implement xpack.monitoring.elasticsearch.collection.enabled setting #33474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 15 commits
a669f67
dfc6ebe
07b3bd6
ccbdbcf
b17ed78
cb17765
e003f31
a610e00
00c9e4b
f5cfa91
871fc3b
cd751df
79a79c7
9f6a208
8d3e931
94749fc
5adbb8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,6 +66,17 @@ option in `kibana.yml` to the same value. | |
| You can update this setting through the | ||
| <<cluster-update-settings,Cluster Update Settings API>>. | ||
|
|
||
| `xpack.monitoring.elasticsearch.collection.enabled`:: | ||
|
|
||
| Controls whether statistics about your {es} cluster should be collected. Defaults to `true`. | ||
| This is different from xpack.monitoring.collection.enabled, which allows you to enable or disable | ||
| all monitoring collection. However, this setting simply disables the collection of Elasticsearch | ||
| data while still allowing other data (e.g., Kibana, Logstash, Beats, or APM Server monitoring data) | ||
| to use through this cluster. | ||
|
||
| + | ||
| You can update this setting through the | ||
| <<cluster-update-settings,Cluster Update Settings API>>. | ||
|
|
||
| `xpack.monitoring.collection.cluster.stats.timeout`:: | ||
|
|
||
| Sets the timeout for collecting the cluster statistics. Defaults to `10s`. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,8 +43,21 @@ public class MonitoringService extends AbstractLifecycleComponent { | |
| */ | ||
| public static final TimeValue MIN_INTERVAL = TimeValue.timeValueSeconds(1L); | ||
|
|
||
| /* | ||
| * Dynamically controls enabling or disabling the collection of Monitoring data only from Elasticsearch. | ||
ycombinator marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * <p> | ||
| * This should only be used while transitioning to Metricbeat-based data collection for Elasticsearch with | ||
| * {@linkplain #ENABLED} set to {@code true}. By setting this to {@code false} and that value to {@code true}, | ||
| * Kibana, Logstash, Beats, and APM Server can all continue to report their stats through this cluster until they | ||
| * are transitioned to being monitored by Metricbeat as well. | ||
| */ | ||
| public static final Setting<Boolean> ELASTICSEARCH_COLLECTION_ENABLED = | ||
| Setting.boolSetting("xpack.monitoring.elasticsearch.collection.enabled", true, | ||
| Setting.Property.Dynamic, Setting.Property.NodeScope); | ||
|
|
||
| /** | ||
| * Dynamically controls enabling or disabling the collection of Monitoring data. | ||
| * Dynamically controls enabling or disabling the collection of Monitoring data from Elasticsearch as well as other products | ||
| * in the stack. | ||
| */ | ||
| public static final Setting<Boolean> ENABLED = | ||
| Setting.boolSetting("xpack.monitoring.collection.enabled", false, | ||
|
|
@@ -68,6 +81,7 @@ public class MonitoringService extends AbstractLifecycleComponent { | |
| private final Set<Collector> collectors; | ||
| private final Exporters exporters; | ||
|
|
||
| private volatile boolean elasticsearchCollectionEnabled; | ||
| private volatile boolean enabled; | ||
| private volatile TimeValue interval; | ||
| private volatile ThreadPool.Cancellable scheduler; | ||
|
|
@@ -79,13 +93,21 @@ public class MonitoringService extends AbstractLifecycleComponent { | |
| this.threadPool = Objects.requireNonNull(threadPool); | ||
| this.collectors = Objects.requireNonNull(collectors); | ||
| this.exporters = Objects.requireNonNull(exporters); | ||
| this.elasticsearchCollectionEnabled = ELASTICSEARCH_COLLECTION_ENABLED.get(settings); | ||
| this.enabled = ENABLED.get(settings); | ||
| this.interval = INTERVAL.get(settings); | ||
|
|
||
| clusterService.getClusterSettings() | ||
| .addSettingsUpdateConsumer(ELASTICSEARCH_COLLECTION_ENABLED, this::setElasticsearchCollectionEnabled); | ||
| clusterService.getClusterSettings().addSettingsUpdateConsumer(ENABLED, this::setMonitoringActive); | ||
| clusterService.getClusterSettings().addSettingsUpdateConsumer(INTERVAL, this::setInterval); | ||
| } | ||
|
|
||
| void setElasticsearchCollectionEnabled(final boolean enabled) { | ||
| this.elasticsearchCollectionEnabled = enabled; | ||
| scheduleExecution(); | ||
| } | ||
|
|
||
| void setMonitoringActive(final boolean enabled) { | ||
| this.enabled = enabled; | ||
| scheduleExecution(); | ||
|
|
@@ -100,10 +122,18 @@ public TimeValue getInterval() { | |
| return interval; | ||
| } | ||
|
|
||
| public boolean isMonitoringActive() { | ||
| boolean isMonitoringActive() { | ||
|
||
| return isStarted() && enabled; | ||
| } | ||
|
|
||
| boolean isElasticsearchCollectionEnabled() { | ||
| return this.elasticsearchCollectionEnabled; | ||
| } | ||
|
|
||
| boolean shouldScheduleExecution() { | ||
| return isElasticsearchCollectionEnabled() && isMonitoringActive(); | ||
| } | ||
|
|
||
| private String threadPoolName() { | ||
| return ThreadPool.Names.GENERIC; | ||
| } | ||
|
|
@@ -155,7 +185,7 @@ void scheduleExecution() { | |
| if (scheduler != null) { | ||
| cancelExecution(); | ||
| } | ||
| if (isMonitoringActive()) { | ||
| if (shouldScheduleExecution()) { | ||
| scheduler = threadPool.scheduleWithFixedDelay(monitor, interval, threadPoolName()); | ||
| } | ||
| } | ||
|
|
@@ -188,7 +218,7 @@ class MonitoringExecution extends AbstractRunnable implements Closeable { | |
|
|
||
| @Override | ||
| public void doRun() { | ||
| if (isMonitoringActive() == false) { | ||
| if (shouldScheduleExecution() == false) { | ||
| logger.debug("monitoring execution is skipped"); | ||
| return; | ||
| } | ||
|
|
@@ -223,7 +253,7 @@ protected void doRun() throws Exception { | |
| new ParameterizedMessage("monitoring collector [{}] failed to collect data", collector.name()), e); | ||
| } | ||
| } | ||
| if (isMonitoringActive()) { | ||
| if (shouldScheduleExecution()) { | ||
| exporters.export(results, ActionListener.wrap(r -> semaphore.release(), this::onFailure)); | ||
| } else { | ||
| semaphore.release(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.