Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions docs/reference/monitoring/configuring-monitoring.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ indices. You can also adjust how monitoring data is displayed.

. To collect monitoring data about your {es} cluster:

.. Verify that the `xpack.monitoring.enabled` and
`xpack.monitoring.collection.enabled` settings are `true` on each node in the
cluster. By default, data collection is disabled. For more information, see
<<monitoring-settings>>.
.. Verify that the `xpack.monitoring.enabled`,
`xpack.monitoring.collection.enabled`, and
`xpack.monitoring.elasticsearch.collection.enabled` settings are `true` on each
node in the cluster. By default xpack.monitoring.collection.enabled is disabled
(`false`), and that overrides xpack.monitoring.elasticsearch.collection.enabled,
which defaults to being enabled (`true`). Both settings can be set dynamically
at runtime. For more information, see <<monitoring-settings>>.

.. Optional: Specify which indices you want to monitor.
+
Expand Down
10 changes: 10 additions & 0 deletions docs/reference/monitoring/pause-export.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ monitoring data from other sources such as {kib}, Beats, and Logstash is ignored
You can update this setting by using the
{ref}/cluster-update-settings.html[Cluster Update Settings API].

If you want to collect data from sources such as {kib}, Beats, and Logstash but
not collect data about your {es} cluster, you can disable data collection
just for {es}:

[source,yaml]
---------------------------------------------------
xpack.monitoring.collection.enabled: true
xpack.monitoring.elasticsearch.collection.enabled: false
---------------------------------------------------
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I missed the master pull request.

There's a subtle thing that I am missing, because in the current state xpack.monitoring.elasticsearch.collection.enabled seems to be a duplicate of xpack.monitoring.collection.enabled to me.

Today xpack.monitoring.collection.enabled controls the collection of the local Elasticsearch cluster and has no impact on how Beats/LS/KB monitoring data are exported. Is the plan to change that?

Copy link
Contributor Author

@ycombinator ycombinator Sep 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tlrx, sorry for any confusion. Let me try to clarify how things are working right now (I just tested in master to confirm).

Conceptually, the xpack.monitoring.collection.enabled setting does everything the xpack.monitoring.elasticsearch.collection.enabled setting does and more. The xpack.monitoring.collection.enabled setting controls whether all of Monitoring should be on or off. With it on, the xpack.monitoring.elasticsearch.collection.enabled setting can then be used to turn off just Elasticsearch monitoring. Conceptually this setting is similar to the xpack.monitoring.kibana.collection.enabled setting that can be set in kibana.yml to turn off just Kibana monitoring.

Put differently:

The xpack.monitoring.elasticsearch.collection.enabled setting stops collection of only Elasticsearch monitoring data. Monitoring data from other products (Beats/LS/KB) sent to the bulk monitoring API endpoint will still be exported and indexed into monitoring indices.

On the other hand, the xpack.monitoring.collection.enabled setting stops collection of Elasticsearch monitoring data and ignores any monitoring data sent from other products (Beats/LS/KB) sent to the bulk monitoring API endpoint. Therefore, no monitoring data is exported and indexed into monitoring indices.

You can verify this as follows:

  1. Start up Elasticsearch and Kibana with default settings + basic license (default build).
  2. At this point no monitoring data should be indexed. Verify this with:
    GET _cat/indices/.m*`
    
  3. Turn on all monitoring with:
    PUT _cluster/settings
    {
      "persistent": {
        "xpack.monitoring.collection.enabled": true
      }
    }
    
  4. After 30s or so, verify that both ES and Kibana monitoring indices are being created and growing, with:
    GET _cat/indices/.m*`
    
  5. Now turn off only Elasticsearch monitoring with:
    PUT _cluster/settings
    {
      "persistent": {
        "xpack.monitoring.elasticsearch.collection.enabled": false
      }
    }
    
  6. After 30s or so, verify that only Kibana monitoring indices are growing but the Elasticsearc monitoring indices have stopped growing, with:
    GET _cat/indices/.m*`
    

Does that help?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reminder! I was looking at where ENABLED was used - and saw nothing in the monitoring bulk code - but looking at where the isMonitoringActive() is used answered my question.


If you want to separately disable a specific exporter, you can specify the
`enabled` setting (which defaults to `true`) per exporter. For example:

Expand Down
11 changes: 11 additions & 0 deletions docs/reference/settings/monitoring-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,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 pass 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`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ public List<Setting<?>> getSettings() {
settings.add(MonitoringField.HISTORY_DURATION);
settings.add(CLEAN_WATCHER_HISTORY);
settings.add(MonitoringService.ENABLED);
settings.add(MonitoringService.ELASTICSEARCH_COLLECTION_ENABLED);
settings.add(MonitoringService.INTERVAL);
settings.add(Collector.INDICES);
settings.add(ClusterStatsCollector.CLUSTER_STATS_TIMEOUT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,21 @@ private static void deprecateMinusOne(final TimeValue value) {
*/
public static final TimeValue MIN_INTERVAL = TimeValue.timeValueSeconds(1L);

/*
* Dynamically controls enabling or disabling the collection of Monitoring data only from Elasticsearch.
* <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,
Expand Down Expand Up @@ -96,6 +109,7 @@ private static void deprecateMinusOne(final TimeValue value) {
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;
Expand All @@ -107,13 +121,21 @@ private static void deprecateMinusOne(final TimeValue value) {
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();
Expand All @@ -135,6 +157,14 @@ public boolean isMonitoringActive() {
&& interval.millis() >= MIN_INTERVAL.millis();
}

boolean isElasticsearchCollectionEnabled() {
return this.elasticsearchCollectionEnabled;
}

boolean shouldScheduleExecution() {
return isElasticsearchCollectionEnabled() && isMonitoringActive();
}

private String threadPoolName() {
return ThreadPool.Names.GENERIC;
}
Expand Down Expand Up @@ -186,7 +216,7 @@ void scheduleExecution() {
if (scheduler != null) {
cancelExecution();
}
if (isMonitoringActive()) {
if (shouldScheduleExecution()) {
scheduler = threadPool.scheduleWithFixedDelay(monitor, interval, threadPoolName());
}
}
Expand Down Expand Up @@ -219,7 +249,7 @@ class MonitoringExecution extends AbstractRunnable implements Closeable {

@Override
public void doRun() {
if (isMonitoringActive() == false) {
if (shouldScheduleExecution() == false) {
logger.debug("monitoring execution is skipped");
return;
}
Expand Down Expand Up @@ -254,7 +284,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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,4 @@ public void testDoCollect() throws Exception {
assertThat(recoveries.shardRecoveryStates().size(), equalTo(nbRecoveries));
}
}
}
}