Run the latest version of the Elastic stack with Docker and Docker Compose.
It gives you the ability to analyze any data set by using the searching/aggregation capabilities of Elasticsearch and the visualization power of Kibana.
Based on the official Docker images from Elastic:
- Docker version 18.09+ https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-using-the-convenience-script
- Docker Compose version 1.24.0+ https://docs.docker.com/compose/install/
- 1 GB of RAM
By default, the stack exposes the following ports:
- 9200: Nginx load balancing port
- 9300: Elasticsearch TCP transport
- 5601: Kibana
The vm.max_map_count kernel setting needs to be set to at least 262144 for production use. Depending on your platform:
Linux
The vm.max_map_count setting should be set permanently in /etc/sysctl.conf:
$ grep vm.max_map_count /etc/sysctl.conf vm.max_map_count=262144
Clone this repository, then start the stack using Docker Compose:
$ docker-compose up
You can also run all services in the background (detached mode) by adding the -d
flag to the above command.
When Kibana launches for the first time, it is not configured with any index pattern.
ℹ️ You need to inject data into Logstash before being able to configure a Logstash index pattern via the Kibana web UI. Then all you have to do is hit the Create button.
Refer to Connect Kibana with Elasticsearch for detailed instructions about the index pattern configuration.
ℹ️ The created pattern will automatically be marked as the default index pattern as soon as the Kibana UI is opened for the first time.
ℹ️ Configuration is not dynamically reloaded, you will need to restart individual components after any configuration change.
The Elasticsearch configuration is stored in elasticsearch/config/elasticsearch.yml
.
You can also specify the options you want to override by setting environment variables inside the Compose file:
elasticsearch:
environment:
network.host: _non_loopback_
cluster.name: my-cluster
Please refer to the following documentation page for more details about how to configure Elasticsearch inside Docker containers: Install Elasticsearch with Docker.
The Kibana default configuration is stored in kibana/config/kibana.yml
.
It is also possible to map the entire config
directory instead of a single file.
Please refer to the following documentation page for more details about how to configure Kibana inside Docker containers: Running Kibana on Docker.
The Logstash configuration is stored in logstash/config/logstash.yml
.
It is also possible to map the entire config
directory instead of a single file, however you must be aware that
Logstash will be expecting a log4j2.properties
file for its own logging.
Please refer to the following documentation page for more details about how to configure Logstash inside Docker containers: Configuring Logstash for Docker.
The data stored in Elasticsearch will be persisted after container reboot but not after container removal.
In order to persist Elasticsearch data even after removing the Elasticsearch container, you'll have to mount a volume on
your Docker host. Update the elasticsearch
service declaration to:
elasticsearch:
volumes:
- /path/to/storage:/usr/share/elasticsearch/data
This will store Elasticsearch data inside /path/to/storage
.
By default, both Elasticsearch and Logstash start with 1/4 of the total host memory allocated to the JVM Heap Size.
The startup scripts for Elasticsearch and Logstash can append extra JVM options from the value of an environment variable, allowing the user to adjust the amount of memory that can be used by each component:
Service | Environment variable |
---|---|
Elasticsearch | ES_JAVA_OPTS |
Logstash | LS_JAVA_OPTS |
To accomodate environments where memory is scarce (Docker for Mac has only 2 GB available by default), the Heap Size
allocation is capped by default to 256MB per service in the docker-compose.yml
file. If you want to override the
default JVM configuration, edit the matching environment variable(s) in the docker-compose.yml
file.
For example, to increase the maximum JVM Heap Size for Logstash:
elasticsearch (1,2,3):
- "ES_JAVA_OPTS=-Xms1G -Xmx1G"
logstash (1,2,3):
environment:
LS_JAVA_OPTS: -Xmx1g -Xms1g
Experimental support for Docker Swarm mode is provided in the form of a docker-stack.yml
file, which can
be deployed in an existing Swarm cluster using the following command:
$ docker stack deploy -c docker-stack.yml elk
If all components get deployed without any error, the following command will show 3 running services:
$ docker stack services elk
ℹ️ To scale Elasticsearch in Swarm mode, configure zen to use the DNS name
tasks.elasticsearch
instead ofelasticsearch
.