elastic / start-local

Try Elasticsearch and Kibana locally
Apache License 2.0
31 stars 7 forks source link

๐Ÿš€ Try Elasticsearch and Kibana locally

Run Elasticsearch and Kibana on your local machine using a simple shell script. This setup uses Docker behind the scenes to install and run the services.

[!IMPORTANT]
This script is for local testing only. Do not use it in production! For production installations refer to the official documentation for Elasticsearch and Kibana.

๐ŸŒŸ Features

This script comes with a one-month trial license. After the trial period, the license reverts to Free and open - Basic.

For a complete list of subscriptions and features, see our subscriptions page.

๐Ÿ’ป System requirements

๐Ÿƒโ€โ™€๏ธโ€โžก๏ธ Getting started

Setup

Run the start-local script using curl:

curl -fsSL https://elastic.co/start-local | sh

This script creates an elastic-start-local folder containing:

๐ŸŒ Endpoints

After running the script:

The script generates a random password for the elastic user, displayed at the end of the installation and stored in the .env file.

[!CAUTION] HTTPS is disabled, and Basic authentication is used for Elasticsearch. This configuration is for local testing only. For security, Elasticsearch and Kibana are accessible only via localhost.

๐Ÿ”‘ API key

An API key for Elasticsearch is generated and stored in the .env file as ES_LOCAL_API_KEY. Use this key to connect to Elasticsearch with the Elastic SDK or REST API.

Check the connection to Elasticsearch using curl in the elastic-start-local folder:

source .env
curl $ES_LOCAL_URL -H "Authorization: ApiKey ${ES_LOCAL_API_KEY}"

๐Ÿณ Start and stop the services

You can use the start and stop commands available in the elastic-start-local folder.

To stop the Elasticsearch and Kibana Docker services, use the stop command:

cd elastic-start-local
./stop.sh

To start the Elasticsearch and Kibana Docker services, use the start command:

cd elastic-start-local
./start.sh

Docker Compose.

๐Ÿ—‘๏ธ Uninstallation

To remove the start-local installation:

cd elastic-start-local
./uninstall.sh

[!WARNING]
This erases all data permanently.

๐Ÿ“ Logging

If the installation fails, an error log is created in error-start-local.log. This file contains logs from Elasticsearch and Kibana, captured using the docker logs command.

โš™๏ธ Customizing settings

To change settings (e.g., Elasticsearch password), edit the .env file. Example contents:

ES_LOCAL_VERSION=8.15.2
ES_LOCAL_URL=http://localhost:9200
ES_LOCAL_CONTAINER_NAME=es-local-dev
ES_LOCAL_DOCKER_NETWORK=elastic-net
ES_LOCAL_PASSWORD=hOalVFrN
ES_LOCAL_PORT=9200
KIBANA_LOCAL_CONTAINER_NAME=kibana-local-dev
KIBANA_LOCAL_PORT=5601
KIBANA_LOCAL_PASSWORD=YJFbhLJL
ES_LOCAL_API_KEY=df34grtk...==

[!IMPORTANT] After changing the .env file, restart the services using stop and start:

cd elastic-start-local
./stop.sh
./start.sh

๐Ÿงช Testing the installer

We use bashunit to test the script. Tests are in the /tests folder.

Running tests

  1. Install bashunit:

    curl -s https://bashunit.typeddevs.com/install.sh | bash
  2. Run tests:

    lib/bashunit

The tests run start-local.sh and check if Elasticsearch and Kibana are working.

[!NOTE] For URL pipeline testing, a local web server is used. This requires PHP.