diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/MonitoredSystem.java b/plugin/src/main/java/org/elasticsearch/xpack/monitoring/MonitoredSystem.java index 88ee5a8fbbf..2ccfbf5301b 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/MonitoredSystem.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/monitoring/MonitoredSystem.java @@ -13,8 +13,8 @@ public enum MonitoredSystem { ES("es"), KIBANA("kibana"), - // TODO: when "BEATS" is re-added, add it to tests where we randomly select "LOGSTASH" LOGSTASH("logstash"), + BEATS("beats"), UNKNOWN("unknown"); private final String system; @@ -35,6 +35,8 @@ public enum MonitoredSystem { return KIBANA; case "logstash": return LOGSTASH; + case "beats": + return BEATS; default: // Return an "unknown" monitored system // that can easily be filtered out if diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtils.java b/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtils.java index 72a18a4ce7e..89c60243283 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtils.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtils.java @@ -41,7 +41,7 @@ public final class MonitoringTemplateUtils { /** * IDs of templates that can be used with {@linkplain #loadTemplate(String) loadTemplate}. */ - public static final String[] TEMPLATE_IDS = { "alerts", "es", "kibana", "logstash" }; + public static final String[] TEMPLATE_IDS = { "alerts", "es", "kibana", "logstash", "beats" }; /** * IDs of templates that can be used with {@linkplain #createEmptyTemplate(String) createEmptyTemplate} that are not managed by a diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkAction.java b/plugin/src/main/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkAction.java index fdb86531587..8ae1ed74ade 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkAction.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkAction.java @@ -56,7 +56,8 @@ public class RestMonitoringBulkAction extends MonitoringRestHandler { final Map> versionsMap = new HashMap<>(); versionsMap.put(MonitoredSystem.KIBANA, allVersions); versionsMap.put(MonitoredSystem.LOGSTASH, allVersions); - // Beats did not report data in the 5.x timeline, so it should never send the original version [when we add it!] + // Beats did not report data in the 5.x timeline, so it should never send the original version + versionsMap.put(MonitoredSystem.BEATS, Collections.singletonList(MonitoringTemplateUtils.TEMPLATE_VERSION)); supportedApiVersions = Collections.unmodifiableMap(versionsMap); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/TransportMonitoringBulkActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/TransportMonitoringBulkActionTests.java index ec77148feeb..dd4274b0f51 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/TransportMonitoringBulkActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/TransportMonitoringBulkActionTests.java @@ -131,7 +131,7 @@ public class TransportMonitoringBulkActionTests extends ESTestCase { final MonitoringBulkRequest request = new MonitoringBulkRequest(); - final MonitoredSystem system = randomFrom(MonitoredSystem.KIBANA, MonitoredSystem.LOGSTASH); + final MonitoredSystem system = randomFrom(MonitoredSystem.KIBANA, MonitoredSystem.LOGSTASH, MonitoredSystem.BEATS); final String type = randomAlphaOfLength(5); final String id = randomBoolean() ? randomAlphaOfLength(5) : null; final long timestamp = randomNonNegativeLong(); @@ -201,7 +201,7 @@ public class TransportMonitoringBulkActionTests extends ESTestCase { public void testAsyncActionCreateMonitoringDocs() throws Exception { final List docs = new ArrayList<>(); - final MonitoredSystem system = randomFrom(MonitoredSystem.KIBANA, MonitoredSystem.LOGSTASH); + final MonitoredSystem system = randomFrom(MonitoredSystem.KIBANA, MonitoredSystem.LOGSTASH, MonitoredSystem.BEATS); final String type = randomAlphaOfLength(5); final String id = randomBoolean() ? randomAlphaOfLength(5) : null; final long timestamp = randomBoolean() ? randomNonNegativeLong() : 0L; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtilsTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtilsTests.java index f5ce6b7a34b..41a47777eeb 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtilsTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtilsTests.java @@ -100,6 +100,8 @@ public class MonitoringTemplateUtilsTests extends ESTestCase { equalTo(".monitoring-kibana-" + TEMPLATE_VERSION + "-2017.08.03")); assertThat(indexName(formatter, MonitoredSystem.LOGSTASH, timestamp), equalTo(".monitoring-logstash-" + TEMPLATE_VERSION + "-2017.08.03")); + assertThat(indexName(formatter, MonitoredSystem.BEATS, timestamp), + equalTo(".monitoring-beats-" + TEMPLATE_VERSION + "-2017.08.03")); formatter = DateTimeFormat.forPattern("YYYY-dd-MM-HH.mm.ss").withZoneUTC(); assertThat(indexName(formatter, MonitoredSystem.ES, timestamp), @@ -108,5 +110,7 @@ public class MonitoringTemplateUtilsTests extends ESTestCase { equalTo(".monitoring-kibana-" + TEMPLATE_VERSION + "-2017-03-08-13.47.58")); assertThat(indexName(formatter, MonitoredSystem.LOGSTASH, timestamp), equalTo(".monitoring-logstash-" + TEMPLATE_VERSION + "-2017-03-08-13.47.58")); + assertThat(indexName(formatter, MonitoredSystem.BEATS, timestamp), + equalTo(".monitoring-beats-" + TEMPLATE_VERSION + "-2017-03-08-13.47.58")); } } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterResourceTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterResourceTests.java index 0e49dca970b..db8647153f1 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterResourceTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterResourceTests.java @@ -61,7 +61,7 @@ public class HttpExporterResourceTests extends AbstractPublishableHttpResourceTe private final boolean createOldTemplates = randomBoolean(); /** - * kibana, logstash (and beats in the future) + * kibana, logstash, and beats */ private final int EXPECTED_TEMPLATES = TEMPLATE_IDS.length + (createOldTemplates ? OLD_TEMPLATE_IDS.length : 0); private final int EXPECTED_PIPELINES = PIPELINE_IDS.length; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTests.java index cb4057cf46d..63fc4f2d87f 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTests.java @@ -49,6 +49,7 @@ import java.util.stream.Collectors; import static org.elasticsearch.search.aggregations.AggregationBuilders.max; import static org.elasticsearch.search.aggregations.AggregationBuilders.terms; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; +import static org.elasticsearch.xpack.monitoring.MonitoredSystem.BEATS; import static org.elasticsearch.xpack.monitoring.MonitoredSystem.KIBANA; import static org.elasticsearch.xpack.monitoring.MonitoredSystem.LOGSTASH; import static org.elasticsearch.xpack.monitoring.exporter.MonitoringTemplateUtils.PIPELINE_IDS; @@ -223,6 +224,7 @@ public class LocalExporterIntegTests extends LocalExporterIntegTestCase { templates.add(".monitoring-es"); templates.add(".monitoring-kibana"); templates.add(".monitoring-logstash"); + templates.add(".monitoring-beats"); GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates(".monitoring-*").get(); Set actualTemplates = response.getIndexTemplates().stream().map(IndexTemplateMetaData::getName).collect(Collectors.toSet()); @@ -302,7 +304,7 @@ public class LocalExporterIntegTests extends LocalExporterIntegTestCase { } private static MonitoringBulkDoc createMonitoringBulkDoc() throws IOException { - final MonitoredSystem system = randomFrom(KIBANA, LOGSTASH); + final MonitoredSystem system = randomFrom(BEATS, KIBANA, LOGSTASH); final XContentType xContentType = randomFrom(XContentType.values()); final BytesReference source; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java index 5c3d1ba3a4c..a3582eb1c6b 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java @@ -681,6 +681,6 @@ public class MonitoringIT extends ESRestTestCase { * Returns a {@link MonitoredSystem} supported by the Monitoring Bulk API */ private static MonitoredSystem randomSystem() { - return randomFrom(MonitoredSystem.LOGSTASH, MonitoredSystem.KIBANA); + return randomFrom(MonitoredSystem.LOGSTASH, MonitoredSystem.KIBANA, MonitoredSystem.BEATS); } } diff --git a/plugin/src/test/resources/rest-api-spec/test/monitoring/bulk/10_basic.yml b/plugin/src/test/resources/rest-api-spec/test/monitoring/bulk/10_basic.yml index d6cc557464d..510c5af749e 100644 --- a/plugin/src/test/resources/rest-api-spec/test/monitoring/bulk/10_basic.yml +++ b/plugin/src/test/resources/rest-api-spec/test/monitoring/bulk/10_basic.yml @@ -164,7 +164,7 @@ - do: xpack.monitoring.bulk: - system_id: "logstash" + system_id: "beats" system_api_version: "6" interval: "5s" body: @@ -186,17 +186,17 @@ - do: search: - index: .monitoring-logstash-* + index: .monitoring-beats-* - match: { hits.total: 2 } - do: indices.close: - index: .monitoring-logstash-* + index: .monitoring-beats-* - do: catch: /export_exception/ xpack.monitoring.bulk: - system_id: "logstash" + system_id: "beats" system_api_version: "6" interval: "5s" body: