Development sandbox was created to ease up experiments and debugging of ROR elasticsearch and kibana plugin. When I created it I wanted to make it easy to recreate environment as close as possible to customer's environment.
I wanted to make it easy to:
- Set up specific version of elasticsearch and kibana with ROR plugin.
- Set up elasticsearch and kibana along with ROR plugin from custom location.
- Set up elasticsearch for remote debugging.
- Set up kibana connected to elasticsearch from
eshomeexecuted in IDE.
Whole sandbox is based on docker and uses docker compose to orchestrate containers. There are 3 services configured in docker-compose.yml:
- elasticsearch - could be used as standalone elasticsearch instance with ability to connect remote debugger to it.
- kibana - configured to connect to elasticsearch instance from this sandbox.
- kibana-oss - oss version of kibana designated to work with elasticsearch from
eshome.
⚠️ Each service has been intended to run from dedicated script which configures environment variables used in docker-compose.yml, builds proper image and runs it. If you want to use docker-compose directly check section "Using docker-compose manually"
By default services from sandbox expose these ports:
9200- elasticsearch REST8888- elasticsearch remote debug5601- kibana
For most purposes it should be enough to change only files under conf directory to adapt sandbox to specific needs. This directory contains configuration files mapped directly to container and env_configuration. If you want to change some service configuration file you have to add it's mapping to docker-compose.yml. Here's description of each file:
conf/elasticsearch/elasticsearch.yml- minimal single Elasticsearch server configuration file.jvm.options- default file with added remote debugging on port 8888.log4j2.properties- log4j properties file which could be used to change log level for elasticsearch.readonlyrest.yml- sample ROR configuration file which allows kibana to access it.
kibana/kibana.yml- minimal kibana configuration file with debug logs enabled
kibana-oss/kibana.yml- minimal kibana configuration file with debug logs enabled
env_configuration- file which is used to configure sandbox
This contains environment variables used to configure sandbox. Here's description of each variable:
ELASTICSEARCH_VERSION- version of elasticsearch server to use.KIBANA_VERSION- version of kibana server to use.CUSTOM_ROR_ELASTICSEARCH_LOCATION- specifies custom URL for elasticsearch ROR plugin. For example could be used to run elastic with file from S3. When empty, latest ROR will be downloaded fromhttps://api.beshu.tech/download/es?esVersion=$ELASTICSEARCH_VERSIONCUSTOM_ROR_KIBANA_LOCATION- specifies custom URL for kibana ROR plugin. For example could be used to run kibana with file from S3. When empty, latest ROR will be downloaded fromhttps://api.beshu.tech/download/trial?esVersion=$ELASTICSEARCH_VERSION
⚠️ Each service has been intended to run from dedicated script which configures environment variables used in docker-compose.yml, builds proper image and runs it. If you want to use docker-compose directly check section "Using docker-compose manually"
There are few dedicated scripts to run services, prepare env for custom use and clean env from data. Scripts which are used to run services are starting in terminal attached mode. It's done this way to make it less likely that you will forgot to reload service after config change or service would be left running in background. To stop service press Ctrl+C.
Each script was intended to be executed from root sandbox directory. Using it from other directories will fuck up hardcoded paths. Here's a list of all scripts:
run_elasticsearch.sh- will build and run elasticsearch service.run_kibana.sh- will build and run kibana service.run_kibana_for_eshome.sh- will build and run kibana service dedicated to use witheshome.run_elasticsearch_and_kibana.sh- will build and run both elasticsearch and kibana. UsingCtrl+Con this script will stop both services, so if you want to have possibility to restart just one service use above scripts starting single service.prepare_dc_for_custom_use.sh- will prepare sandbox to use docker-compose manually. Remember to use it withsource ./prepare_dc_for_custom_use.shclean.sh- will bring down and remove all containers. Elasticsearch data will be removed by this command.clean_all.sh- will do exactly what command above additionally will remove volumes with kibana cache.
If you want to have more control over how services are executed you can use script which will configure all env variables required by docker-compose, so it will be possible to execute docker-compose directly without using dedicated scripts. It's less convenient than using scripts because you have to remember to execute prepare script after each change to env_configuration file, so it's possible that you will run app with old settings.
Here's how to use it:
- Go to sandbox directory using
cd - Execute
source ./prepare_dc_for_custom_use.sh - You are now should be able to execute for example
docker-compose up -d elasticsearch - After each change to
env_configurationrepeat step 2.
All examples here assume that you are in sandbox root directory
- Open
conf/env_configurationand change value ofELASTICSEARCH_VERSIONandKIBANA_VERSIONto X.Y.Z - Execute
./run_elasticsearch_and_kibana.shor if you want to eventually restart kibana or elasticsearch execute./run_elasticsearch.shin on tab of terminal and./run_kibana.shin another. - Optionally connect remote debugger to elasticsearch on
localhost:8888 - Use
Ctrl+Cto stop services when you're done or want to restart them.
- Open
conf/env_configurationand: - change value of
ELASTICSEARCH_VERSIONandKIBANA_VERSIONto X.Y.Z - change value of
CUSTOM_ROR_ELASTICSEARCH_LOCATIONto URL or file containing ROR elasticsearch plugin. - change value of
CUSTOM_ROR_KIBANA_LOCATIONto URL or file containing ROR kibana plugin. - Execute
./run_elasticsearch_and_kibana.shor if you want to eventually restart kibana or elasticsearch execute./run_elasticsearch.shin on tab of terminal and./run_kibana.shin another. - Optionally connect remote debugger to elasticsearch on
localhost:8888 - Use
Ctrl+Cto stop services when you're done or want to restart them.
- Start elasticsearch in IDE. Kibana assumes that it will be able to connect to it on port 9200.
- Open
conf/env_configurationand change value ofKIBANA_VERSIONto X.Y.Z - Execute
./run_kibana_for_eshome.sh - Use
Ctrl+Cto stop kibana when you're done or want to restart it.
Here's description of how to connect remote debugger to running elasticsearch server which has been started using this sandbox.
- Open the
elasticsearch-readonlyrest-pluginproject in IntelliJ IDEA. - Checkout commit with the same version of ROR code that is running in elasticsearch you want to connect.
- Open
Edit configurations...window. It can be done by pressing shift key twice and entering "Edit configurations" or fromRun->Edit configurations...menu. - If you don't have remote debugger configuration yet add it by clicking "+" icon and choosing
Remote JVM Debug - New configuration will be automatically selected. You can assign it a custom name like "sandbox remote debugger" on presented screenshot. Host and port should be set exactly as they are on this screenshot. Last marked thing is module classpath. You should choose module corresponding to ES version you are trying to debug with name ending with
.main. Module selected on screenshot is appropriate for debugging ES 7.2.x. - Click OK to save configuration.
- You should now see name of created configuration in upper right corner of IntelliJ IDEA.
- Click on a bug icon next to it to start debugger.
- After successful connection window like that should pop up from the bottom



