diff --git a/marvel/src/main/resources/marvel_index_template.json b/marvel/src/main/resources/marvel_index_template.json index 131c1cd2983..8d85ac75c3a 100644 --- a/marvel/src/main/resources/marvel_index_template.json +++ b/marvel/src/main/resources/marvel_index_template.json @@ -176,6 +176,9 @@ "index": "not_analyzed" }, "nodes": { + "enabled": false + }, + "shards": { "type": "object" } } diff --git a/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/cluster/ClusterStateIT.java b/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/cluster/ClusterStateIT.java index 893b66470d2..ce09abb9ffe 100644 --- a/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/cluster/ClusterStateIT.java +++ b/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/cluster/ClusterStateIT.java @@ -6,8 +6,12 @@ package org.elasticsearch.marvel.agent.renderer.cluster; import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.cluster.node.DiscoveryNodes; +import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.marvel.agent.collector.cluster.ClusterStateCollector; +import org.elasticsearch.marvel.agent.exporter.HttpESExporterUtils; import org.elasticsearch.marvel.agent.renderer.AbstractRendererTestCase; +import org.elasticsearch.marvel.agent.settings.MarvelSettings; import org.elasticsearch.search.SearchHit; import org.junit.Test; @@ -15,6 +19,8 @@ import java.util.Collection; import java.util.Collections; import java.util.Map; +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; import static org.hamcrest.Matchers.greaterThan; public class ClusterStateIT extends AbstractRendererTestCase { @@ -44,4 +50,34 @@ public class ClusterStateIT extends AbstractRendererTestCase { logger.debug("--> cluster state successfully collected"); } + + /** + * This test should fail if the mapping for the 'nodes' attribute + * in the 'marvel_cluster_state' document is NOT set to 'enable: false' + * + * See + */ + @Test + public void testNoNodesIndexing() throws Exception { + logger.debug("--> forcing marvel's index template update"); + assertAcked(client().admin().indices().preparePutTemplate("marvel").setSource(HttpESExporterUtils.loadDefaultTemplate()).execute().actionGet()); + + logger.debug("--> deleting all marvel indices"); + cluster().wipeIndices(MarvelSettings.MARVEL_INDICES_PREFIX + "*"); + + logger.debug("--> checking for template existence"); + assertMarvelTemplateExists(); + waitForMarvelDocs(ClusterStateCollector.TYPE); + + logger.debug("--> searching for marvel documents of type [{}]", ClusterStateCollector.TYPE); + SearchResponse response = client().prepareSearch().setTypes(ClusterStateCollector.TYPE).get(); + assertThat(response.getHits().getTotalHits(), greaterThan(0L)); + + DiscoveryNodes nodes = client().admin().cluster().prepareState().clear().setNodes(true).get().getState().nodes(); + + logger.debug("--> ensure that the 'nodes' attributes of the cluster state document is not indexed"); + assertHitCount(client().prepareCount() + .setTypes(ClusterStateCollector.TYPE) + .setQuery(QueryBuilders.matchQuery("cluster_state.nodes." + nodes.masterNodeId() + ".name", nodes.masterNode().name())).get(), 0L); + } }