From b2f78e5a47a9fba5b29542a2babbdae939483474 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Wed, 12 Sep 2018 15:56:13 -0700 Subject: [PATCH] [CCR Monitoring] Only collect stats for specified indices (#33646) Follow up to #33617. Relates to #30086. As with all other per-index Monitoring collectors, the `CcrStatsCollector` should only collect stats for the indices the user wants to monitor. This list is controlled by the `xpack.monitoring.collection.indices` setting and defaults to all indices. --- .../xpack/monitoring/collector/ccr/CcrStatsCollector.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/ccr/CcrStatsCollector.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/ccr/CcrStatsCollector.java index fbb7505af4d..510f430d196 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/ccr/CcrStatsCollector.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/ccr/CcrStatsCollector.java @@ -6,10 +6,10 @@ package org.elasticsearch.xpack.monitoring.collector.ccr; +import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.service.ClusterService; -import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; @@ -72,7 +72,8 @@ public class CcrStatsCollector extends Collector { final ClusterState clusterState) throws Exception { try (ThreadContext.StoredContext ignore = stashWithOrigin(threadContext, MONITORING_ORIGIN)) { final CcrStatsAction.StatsRequest request = new CcrStatsAction.StatsRequest(); - request.setIndices(Strings.EMPTY_ARRAY); + request.setIndices(getCollectionIndices()); + request.setIndicesOptions(IndicesOptions.lenientExpandOpen()); final CcrStatsAction.StatsResponses responses = ccrClient.stats(request).actionGet(getCollectionTimeout()); final long timestamp = timestamp();