Skip to content

Commit

Permalink
Add ES7 specific configuration and polish documentations
Browse files Browse the repository at this point in the history
  • Loading branch information
kezhenxu94 committed Nov 20, 2019
1 parent 32eee5a commit dbe634b
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 13 deletions.
1 change: 1 addition & 0 deletions apm-dist/src/main/assembly/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ storage:
# resultWindowMaxSize: ${SW_STORAGE_ES_QUERY_MAX_WINDOW_SIZE:10000}
# metadataQueryMaxSize: ${SW_STORAGE_ES_QUERY_MAX_SIZE:5000}
# segmentQueryMaxSize: ${SW_STORAGE_ES_QUERY_SEGMENT_SIZE:200}
# indexMaxResultWindow: ${SW_STORAGE_ES_INDEX_MAX_RESULT_WINDOW:5000}
h2:
driver: ${SW_STORAGE_H2_DRIVER:org.h2.jdbcx.JdbcDataSource}
url: ${SW_STORAGE_H2_URL:jdbc:h2:mem:skywalking-oap-db}
Expand Down
19 changes: 16 additions & 3 deletions docs/en/setup/backend/backend-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ storage:
bulkSize: ${SW_STORAGE_ES_BULK_SIZE:20} # flush the bulk every 20mb
flushInterval: ${SW_STORAGE_ES_FLUSH_INTERVAL:10} # flush the bulk every 10 seconds whatever the number of requests
concurrentRequests: ${SW_STORAGE_ES_CONCURRENT_REQUESTS:2} # the number of concurrent requests
resultWindowMaxSize: ${SW_STORAGE_ES_QUERY_MAX_WINDOW_SIZE:10000}
metadataQueryMaxSize: ${SW_STORAGE_ES_QUERY_MAX_SIZE:5000}
segmentQueryMaxSize: ${SW_STORAGE_ES_QUERY_SEGMENT_SIZE:200}
```

### ElasticSearch 6 With Https SSL Encrypting communications.
Expand Down Expand Up @@ -92,9 +95,19 @@ storage:
### Data TTL
TTL in ElasticSearch overrides the settings of core, read [ElasticSearch section in TTL document](ttl.md#elasticsearch-6-storage-ttl)

### ElasticSearch server settings
Read the [ElasticSearch storage FAQ](../../FAQ/ES-Server-FAQ.md) if you are new to ElasticSearch.
And recommend read more about these configuration from ElasticSearch official document.
### Recommended ElasticSearch server-side configurations
You could add following config to `elasticsearch.yml`, set the value based on your env.

```yml
# In tracing scenario, consider to set more than this at least.
thread_pool.index.queue_size: 1000 # Only suitable for ElasticSearch 6
thread_pool.write.queue_size: 1000 # Suitable for ElasticSearch 6 and 7

# When you face query error at trace page, remember to check this.
index.max_result_window: 1000000 # Only suitable for ElasticSearch 6. For ES 7, set `indexMaxResultWindow` under `storage`-`elasticsearch7` section in application.yml
```

We strongly recommend you to read more about these configurations from ElasticSearch official document.
This effects the performance of ElasticSearch very much.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ storage:
resultWindowMaxSize: ${SW_STORAGE_ES_QUERY_MAX_WINDOW_SIZE:10000}
metadataQueryMaxSize: ${SW_STORAGE_ES_QUERY_MAX_SIZE:5000}
segmentQueryMaxSize: ${SW_STORAGE_ES_QUERY_SEGMENT_SIZE:200}
# Index max result window, for segment deep pagination, usually we don't recommend to scroll too many pages,
# instead, give more query criteria (e.g. service id or time range), to narrow the query results.
# see https://www.elastic.co/guide/en/elasticsearch/guide/current/pagination.html for more information
indexMaxResultWindow: ${SW_STORAGE_ES_INDEX_MAX_RESULT_WINDOW:5000}
# h2:
# driver: ${SW_STORAGE_H2_DRIVER:org.h2.jdbcx.JdbcDataSource}
# url: ${SW_STORAGE_H2_URL:jdbc:h2:mem:skywalking-oap-db}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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;

import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.StorageModuleElasticsearchConfig;

/**
* @author kezhenxu94
*/
public class StorageModuleElasticsearch7Config extends StorageModuleElasticsearchConfig {
private int indexMaxResultWindow;

public int getIndexMaxResultWindow() {
return indexMaxResultWindow;
}

public void setIndexMaxResultWindow(final int indexMaxResultWindow) {
this.indexMaxResultWindow = indexMaxResultWindow;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import org.apache.skywalking.oap.server.library.module.ModuleProvider;
import org.apache.skywalking.oap.server.library.module.ModuleStartException;
import org.apache.skywalking.oap.server.library.module.ServiceNotProvidedException;
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.TopNRecordsQueryEsDAO;
Expand All @@ -56,7 +55,7 @@
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.cache.ServiceInventoryCacheEs7DAO;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.client.ElasticSearch7Client;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.dao.StorageEs7DAO;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.dao.StorageEs7Installer;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.base.StorageEs7Installer;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.lock.RegisterLockEs77DAOImpl;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.lock.RegisterLockEs7Installer;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query.AggregationQueryEs7DAO;
Expand All @@ -78,12 +77,12 @@
*/
public class StorageModuleElasticsearch7Provider extends ModuleProvider {

protected final StorageModuleElasticsearchConfig config;
protected final StorageModuleElasticsearch7Config config;
protected ElasticSearch7Client elasticSearch7Client;

public StorageModuleElasticsearch7Provider() {
super();
this.config = new StorageModuleElasticsearchConfig();
this.config = new StorageModuleElasticsearch7Config();
}

@Override
Expand Down Expand Up @@ -135,7 +134,7 @@ public void start() throws ModuleStartException {
try {
elasticSearch7Client.connect();

StorageEs7Installer installer = new StorageEs7Installer(getManager(), config.getIndexShardsNumber(), config.getIndexReplicasNumber(), config.getIndexRefreshInterval());
StorageEs7Installer installer = new StorageEs7Installer(getManager(), config);
installer.install(elasticSearch7Client);

RegisterLockEs7Installer lockInstaller = new RegisterLockEs7Installer(elasticSearch7Client);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
* limitations under the License.
*/

package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.dao;
package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.base;

import org.apache.skywalking.oap.server.core.storage.model.Model;
import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient;
import org.apache.skywalking.oap.server.library.module.ModuleManager;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.StorageEsInstaller;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.StorageModuleElasticsearch7Config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -33,11 +34,13 @@ public class StorageEs7Installer extends StorageEsInstaller {

private static final Logger logger = LoggerFactory.getLogger(StorageEs7Installer.class);

private final StorageModuleElasticsearch7Config config;

public StorageEs7Installer(final ModuleManager moduleManager,
final int indexShardsNumber,
final int indexReplicasNumber,
final int indexRefreshInterval) {
super(moduleManager, indexShardsNumber, indexReplicasNumber, indexRefreshInterval);
final StorageModuleElasticsearch7Config config) {
super(moduleManager, config.getIndexShardsNumber(), config.getIndexReplicasNumber(), config.getIndexRefreshInterval());

this.config = config;
}

@SuppressWarnings("unchecked")
Expand All @@ -50,4 +53,14 @@ protected Map<String, Object> createMapping(Model model) {

return mapping;
}

protected Map<String, Object> createSetting(boolean record) {
Map<String, Object> setting = super.createSetting(record);

if (config.getIndexMaxResultWindow() > 0) {
setting.put("index.max_result_window", config.getIndexMaxResultWindow());
}

return setting;
}
}

0 comments on commit dbe634b

Please sign in to comment.