Elastic Stack (ELK) Docker Composition, preconfigured with Security, Monitoring, and Tools; Up with a Single Command.
Suitable for Demoing, MVPs and small production deployments.
Stack Version: 8.10.2 🎉 - Based on Official Elastic Docker Images
You can change Elastic Stack version by setting
ELK_VERSIONin.envfile and rebuild your images. Any version >= 8.0.0 is compatible with this template.
make collect-docker-logs..env to configure your entire stack parameters.And comparing Elastdocker and the popular deviantony/docker-elk
<details><summary>Expand...</summary> <p>One of the most popular ELK on Docker repositories is the awesome deviantony/docker-elk.
Elastdocker differs from deviantony/docker-elk in the following points.
Security enabled by default using Basic license, not Trial.
Persisting data by default in a volume.
Run in Production Mode (by enabling SSL on Transport Layer, and add initial master node settings).
Persisting Generated Keystore, and create an extendable script that makes it easier to recreate it every-time the container is created.
Parameterize credentials in .env instead of hardcoding elastich:changeme in every component config.
Parameterize all other Config like Heap Size.
Add recommended environment configurations as Ulimits and Swap disable to the docker-compose.
Make it ready to be extended into a multinode cluster.
Configuring the Self-Monitoring and the Filebeat agent that ship ELK logs to ELK itself. (as a step to shipping it to a monitoring cluster in the future).
Configured Prometheus Exporters.
The Makefile that simplifies everything into some simple commands.
Clone the Repository
git clone https://github.com/sherifabdlnaby/elastdocker.git
Initialize Elasticsearch Keystore and TLS Self-Signed Certificates
$ make setup
For Linux's docker hosts only. By default virtual memory is not enough so run the next command as root
sysctl -w vm.max_map_count=262144
Start Elastic Stack
$ make elk <OR> $ docker-compose up -d <OR> $ docker compose up -d
Visit Kibana at https://localhost:5601 or https://<your_public_ip>:5601
Default Username: elastic, Password: changeme
- Notice that Kibana is configured to use HTTPS, so you'll need to write
https://beforelocalhost:5601in the browser.- Modify
.envfile for your needs, most importantlyELASTIC_PASSWORDthat setup your superuserelastic's password,ELASTICSEARCH_HEAP&LOGSTASH_HEAPfor Elasticsearch & Logstash Heap Size.
Whatever your Host (e.g AWS EC2, Azure, DigitalOcean, or on-premise server), once you expose your host to the network, ELK component will be accessible on their respective ports. Since the enabled TLS uses a self-signed certificate, it is recommended to SSL-Terminate public traffic using your signed certificates.
🏃🏻♂️ To start ingesting logs, you can start by running
make collect-docker-logswhich will collect your host's container logs.
$ make monitoring
$ make collect-docker-logs
$ make all
$ make nodes
$ make build
$ make down
</p> </details>$ make prune
.env file.
ELASTIC_PASSWORD, user elastic's password (default: changeme pls).ELK_VERSION Elastic Stack Version (default: 8.10.2)ELASTICSEARCH_HEAP, how much Elasticsearch allocate from memory (default: 1GB -good for development only-)LOGSTASH_HEAP, how much Logstash allocate from memory.elasticsearch.yml at ./elasticsearch/config.logstash.yml at ./logstash/config/logstash.yml.main.conf at ./logstash/pipeline/main.conf.kibana.yml at ./kibana/config.You can extend the Keystore generation script by adding keys to ./setup/keystore.sh script. (e.g Add S3 Snapshot Repository Credentials)
To Re-generate Keystore:
make keystore
⚠️ Elasticsearch HTTP layer is using SSL, thus mean you need to configure your elasticsearch clients with the CA in secrets/certs/ca/ca.crt, or configure client to ignore SSL Certificate Verification (e.g --insecure in curl).
Adding Two Extra Nodes to the cluster will make the cluster depending on them and won't start without them again.
Makefile is a wrapper around Docker-Compose commands, use make help to know every command.
Elasticsearch will save its data to a volume named elasticsearch-data
Elasticsearch Keystore (that contains passwords and credentials) and SSL Certificate are generated in the ./secrets directory by the setup command.
Make sure to run make setup if you changed ELASTIC_PASSWORD and to restart the stack afterwards.
For Linux Users it's recommended to set the following configuration (run as root)
sysctl -w vm.max_map_count=262144
By default, Virtual Memory is not enough.

After completing the setup step, you will notice a container named apm-server which gives you deeper visibility into your applications and can help you to identify and resolve root cause issues with correlated traces, logs, and metrics.
In order to authenticate with Elastic APM, you will need the following:
ELASTIC_APM_SECRET_TOKEN defined in .env file as we have secret token enabled by default8200const apm = require('elastic-apm-node').start({
serviceName: 'foobar',
secretToken: process.env.ELASTIC_APM_SECRET_TOKEN,
// https is enabled by default as per elastdocker configuration
serverUrl: 'https://localhost:8200',
})
Make sure that the agent is started before you require any other modules in your Node.js application - i.e. before express, http, etc. as mentioned in Elastic APM Agent - NodeJS initialization
For more details or other languages you can check the following:
Head to Stack Monitoring tab in Kibana to see cluster metrics for all stack components.

In Production, cluster metrics should be shipped to another dedicated monitoring cluster.
If you started Prometheus Exporters using make monitoring command. Prometheus Exporters will expose metrics at the following ports.
| Prometheus Exporter | Port | Recommended Grafana Dashboard |
|---|---|---|
elasticsearch-exporter | 9114 | Elasticsearch by Kristian Jensen |
logstash-exporter | 9304 | logstash-monitoring by dpavlos |

MIT License Copyright (c) 2022 Sherif Abdel-Naby
PR(s) are Open and


职场AI,就用扣子
AI办公助手,复杂任务高效处理。办公效率低?扣子空间AI助手支持播客生成、PPT制作、网页开发及报告写作,覆盖科研、商业、舆情等领域的专家Agent 7x24小时响应,生活工作无缝切换,提升50%效率!


多风格AI绘画神器
堆友平台由阿里巴巴设计团队创建,作为一款AI驱动的设计工具,专为设计师提供一站式增长服务。功能覆盖海量3D素材、AI绘画、实时渲染以及专业抠图,显著提升设计品质和效率。平台不仅提供工具,还是一个促进创意交流和个人发展的空间,界面友好,适合所有级别的设计师和创意工作者。


零代码AI应用开发平台
零代码AI应用开发平台,用户只需一句话简单描述需求,AI能自动生成小程序、APP或H5网页应用,无需编写代码。


免费创建高清无水印Sora视频
Vora是一个免费创建高清无水印Sora视频的AI工具


最适合小白的AI自动化工作流平台