Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EQL: Add telemetry metrics #59415

Merged
merged 10 commits into from
Jul 14, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class DataLoader {
private static final String TEST_DATA = "/test_data.json";
private static final String MAPPING = "/mapping-default.json";
static final String indexPrefix = "endgame";
static final String testIndexName = indexPrefix + "-1.4.0";
public static final String testIndexName = indexPrefix + "-1.4.0";

public static void main(String[] args) throws IOException {
try (RestClient client = RestClient.builder(new HttpHost("localhost", 9200)).build()) {
Expand All @@ -51,15 +51,23 @@ public static void main(String[] args) throws IOException {
}
}

@SuppressWarnings("unchecked")
protected static void loadDatasetIntoEs(RestHighLevelClient client,
public static void loadDatasetIntoEs(RestHighLevelClient client,
CheckedBiFunction<XContent, InputStream, XContentParser, IOException> p) throws IOException {

createTestIndex(client);
loadData(client, p);
}

private static void createTestIndex(RestHighLevelClient client) throws IOException {
CreateIndexRequest request = new CreateIndexRequest(testIndexName)
.mapping(Streams.readFully(DataLoader.class.getResourceAsStream(MAPPING)), XContentType.JSON);

client.indices().create(request, RequestOptions.DEFAULT);
}

@SuppressWarnings("unchecked")
private static void loadData(RestHighLevelClient client, CheckedBiFunction<XContent, InputStream, XContentParser, IOException> p)
throws IOException {
BulkRequest bulk = new BulkRequest();
bulk.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

package org.elasticsearch.test.eql.stats;

import java.util.Locale;

public enum FeatureMetric {
SEQUENCE,
JOIN,
EVENT,
SEQUENCE_MAXSPAN,
SEQUENCE_UNTIL,
SEQUENCE_QUERIES_TWO,
SEQUENCE_QUERIES_THREE,
SEQUENCE_QUERIES_FOUR,
SEQUENCE_QUERIES_FIVE_OR_MORE,
JOIN_QUERIES_TWO,
JOIN_QUERIES_THREE,
JOIN_QUERIES_FOUR,
JOIN_QUERIES_FIVE_OR_MORE,
JOIN_UNTIL,
JOIN_KEYS_ONE,
JOIN_KEYS_TWO,
JOIN_KEYS_THREE,
JOIN_KEYS_FOUR,
JOIN_KEYS_FIVE_OR_MORE,
PIPE_HEAD,
PIPE_TAIL;

@Override
public String toString() {
return this.name().toLowerCase(Locale.ROOT);
}
}
Loading