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

[Feature] Support ElasticSearch 7 as backend storage #3870

Merged
merged 22 commits into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4c23cd9
[Feature] Officially support ElasticSearch 7 as backend storage
kezhenxu94 Nov 17, 2019
20423ab
Merge branch 'master' into feature/es7-storage
kezhenxu94 Nov 17, 2019
8a7cae1
Extract bootstrap module to be shared by multiple starters
kezhenxu94 Nov 17, 2019
1700610
Add missing configuration file and distinguish different version in test
kezhenxu94 Nov 17, 2019
0470c49
Merge branch 'master' into feature/es7-storage
kezhenxu94 Nov 17, 2019
a8ebdb9
Update known-oap-backend-dependencies-es7.txt
wu-sheng Nov 18, 2019
708ae32
Merge branch 'master' into feature/es7-storage
wu-sheng Nov 18, 2019
ed1b747
Merge branch 'master' into feature/es7-storage
JaredTan95 Nov 18, 2019
d159448
Merge branch 'master' into feature/es7-storage
kezhenxu94 Nov 18, 2019
4f03c33
Merge branch 'master' into feature/es7-storage
kezhenxu94 Nov 18, 2019
76d5c50
Fix missing adaptation to ElasticSearch 7
kezhenxu94 Nov 18, 2019
b11a33e
Rename ElasticSearch 7 specific class with Es7 infix
kezhenxu94 Nov 18, 2019
147aa86
Merge branch 'master' into feature/es7-storage
wu-sheng Nov 18, 2019
6aacc0a
Fix miss-adapted ElasticSearch DAO API
kezhenxu94 Nov 18, 2019
738008f
Merge remote-tracking branch 'apache/master' into feature/es7-storage
kezhenxu94 Nov 19, 2019
664ada5
Merge branch 'master' into feature/es7-storage
wu-sheng Nov 20, 2019
32eee5a
Merge branch 'master' into feature/es7-storage
wu-sheng Nov 20, 2019
dbe634b
Add ES7 specific configuration and polish documentations
kezhenxu94 Nov 20, 2019
937e242
Polish documentations
kezhenxu94 Nov 20, 2019
b3cdbad
Merge branch 'master' into feature/es7-storage
kezhenxu94 Nov 20, 2019
b740446
Polish documentations
kezhenxu94 Nov 20, 2019
a50a46d
Merge branch 'master' into feature/es7-storage
wu-sheng Nov 20, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,8 @@ private List<TopNEntity> aggregation(String indexName, String valueCName, Search
asc = true;
}

TermsAggregationBuilder aggregationBuilder = AggregationBuilders
.terms(Metrics.ENTITY_ID)
.field(Metrics.ENTITY_ID)
.order(BucketOrder.aggregation(valueCName, asc))
.size(topN)
.subAggregation(
AggregationBuilders.avg(valueCName).field(valueCName)
);
TermsAggregationBuilder aggregationBuilder = aggregationBuilder(valueCName, topN, asc);

sourceBuilder.aggregation(aggregationBuilder);

SearchResponse response = getClient().search(indexName, sourceBuilder);
Expand All @@ -135,4 +129,15 @@ private List<TopNEntity> aggregation(String indexName, String valueCName, Search

return topNEntities;
}

protected TermsAggregationBuilder aggregationBuilder(final String valueCName, final int topN, final boolean asc) {
return AggregationBuilders
.terms(Metrics.ENTITY_ID)
.field(Metrics.ENTITY_ID)
.order(BucketOrder.aggregation(valueCName, asc))
.size(topN)
.subAggregation(
AggregationBuilders.avg(valueCName).field(valueCName)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.StorageModuleElasticsearchConfig;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.BatchProcessEsDAO;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.HistoryDeleteEsDAO;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.AggregationQueryEsDAO;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.TopNRecordsQueryEsDAO;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.TopologyQueryEsDAO;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.ttl.ElasticsearchStorageTTL;
Expand All @@ -60,6 +59,7 @@
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.dao.StorageEsInstaller;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.lock.RegisterLockDAOImpl;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.lock.RegisterLockInstaller;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query.AggregationQueryEsDAO;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query.AlarmQueryEsDAO;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query.LogQueryEsDAO;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query.MetadataQueryEsDAO;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query;

import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.BucketOrder;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;

/**
* @author peng-yongsheng
* @author kezhenxu94
*/
public class AggregationQueryEsDAO extends org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.AggregationQueryEsDAO {
kezhenxu94 marked this conversation as resolved.
Show resolved Hide resolved

public AggregationQueryEsDAO(ElasticSearchClient client) {
super(client);
}

protected TermsAggregationBuilder aggregationBuilder(final String valueCName, final int topN, final boolean asc) {
return AggregationBuilders
.terms(Metrics.ENTITY_ID)
.field(Metrics.ENTITY_ID)
.order(BucketOrder.aggregation(valueCName, asc))
.size(topN)
.subAggregation(
AggregationBuilders.avg(valueCName).field(valueCName)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,24 @@

/**
* @author peng-yongsheng
* @author kezhenxu94
*/
public class MetricsQueryEsDAO extends org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.MetricsQueryEsDAO {

public MetricsQueryEsDAO(ElasticSearchClient client) {
super(client);
}

@Override public IntValues getValues(String indName, Downsampling downsampling, long startTB, long endTB, Where where, String valueCName,
@Override
public IntValues getValues(
String indName,
Downsampling downsampling,
long startTB,
long endTB,
Where where,
String valueCName,
Function function) throws IOException {

String indexName = ModelName.build(downsampling, indName);

SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource();
Expand All @@ -66,15 +75,15 @@ public MetricsQueryEsDAO(ElasticSearchClient client) {
switch (function) {
case Sum:
Sum sum = idBucket.getAggregations().get(valueCName);
value = (long)sum.getValue();
value = (long) sum.getValue();
break;
case Avg:
Avg avg = idBucket.getAggregations().get(valueCName);
value = (long)avg.getValue();
value = (long) avg.getValue();
break;
default:
avg = idBucket.getAggregations().get(valueCName);
value = (long)avg.getValue();
value = (long) avg.getValue();
break;
}

Expand All @@ -85,4 +94,18 @@ public MetricsQueryEsDAO(ElasticSearchClient client) {
}
return intValues;
}

protected void functionAggregation(Function function, TermsAggregationBuilder parentAggBuilder, String valueCName) {
switch (function) {
case Avg:
parentAggBuilder.subAggregation(AggregationBuilders.avg(valueCName).field(valueCName));
break;
case Sum:
parentAggBuilder.subAggregation(AggregationBuilders.sum(valueCName).field(valueCName));
break;
default:
parentAggBuilder.subAggregation(AggregationBuilders.avg(valueCName).field(valueCName));
break;
}
}
}