[Monitoring] Support Beats Monitoring (elastic/x-pack-elasticsearch#3208)
This reintroduces support for Beats monitoring. Original commit: elastic/x-pack-elasticsearch@539da3afa1
This commit is contained in:
parent
4cd8f075b9
commit
48c8aed373
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -56,7 +56,8 @@ public class RestMonitoringBulkAction extends MonitoringRestHandler {
|
|||
final Map<MonitoredSystem, List<String>> 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<MonitoringBulkDoc> 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;
|
||||
|
|
|
@ -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"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<String> 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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue