{"id":13400306,"url":"https://github.com/sherifabdlnaby/elastdocker","last_synced_at":"2025-05-14T08:06:35.955Z","repository":{"id":37559069,"uuid":"207037279","full_name":"sherifabdlnaby/elastdocker","owner":"sherifabdlnaby","description":"🐳  Elastic Stack (ELK) v8+ on Docker with Compose. Pre-configured out of the box to enable Logging, Metrics, APM, Alerting, ML, and SIEM features. Up with a Single Command.","archived":false,"fork":false,"pushed_at":"2025-01-04T05:34:02.000Z","size":148,"stargazers_count":1868,"open_issues_count":7,"forks_count":325,"subscribers_count":36,"default_branch":"main","last_synced_at":"2025-04-11T02:51:57.057Z","etag":null,"topics":["docker","docker-compos-template","docker-compose","elasticsearch","elasticstack","elk","elk-stack","kibana","logstash","observability","siem"],"latest_commit_sha":null,"homepage":"https://towardsdatascience.com/running-securing-and-deploying-elastic-stack-on-docker-f1a8ebf1dc5b","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sherifabdlnaby.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"sherifabdlnaby","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2019-09-07T23:32:23.000Z","updated_at":"2025-04-10T08:24:00.000Z","dependencies_parsed_at":"2024-02-18T03:31:51.749Z","dependency_job_id":"690bca8a-eff8-41b1-84e6-47ca1aeb0798","html_url":"https://github.com/sherifabdlnaby/elastdocker","commit_stats":{"total_commits":110,"total_committers":12,"mean_commits":9.166666666666666,"dds":"0.13636363636363635","last_synced_commit":"fd7f419fee453c5b3d9d43fed871e5040ec302e0"},"previous_names":[],"tags_count":34,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sherifabdlnaby%2Felastdocker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sherifabdlnaby%2Felastdocker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sherifabdlnaby%2Felastdocker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sherifabdlnaby%2Felastdocker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sherifabdlnaby","download_url":"https://codeload.github.com/sherifabdlnaby/elastdocker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254101616,"owners_count":22014909,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-compos-template","docker-compose","elasticsearch","elasticstack","elk","elk-stack","kibana","logstash","observability","siem"],"created_at":"2024-07-30T19:00:50.461Z","updated_at":"2025-05-14T08:06:30.941Z","avatar_url":"https://github.com/sherifabdlnaby.png","language":"Dockerfile","funding_links":["https://github.com/sponsors/sherifabdlnaby"],"categories":["Dockerfile","Docker"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg width=\"500px\" src=\"https://user-images.githubusercontent.com/16992394/147855783-07b747f3-d033-476f-9e06-96a4a88a54c6.png\"\u003e\n\u003c/p\u003e\n\u003ch2 align=\"center\"\u003e\u003cb\u003eElast\u003c/b\u003eic Stack on \u003cb\u003eDocker\u003c/b\u003e\u003c/h2\u003e\n\u003ch3 align=\"center\"\u003ePreconfigured Security, Tools, and Self-Monitoring\u003c/h3\u003e\n\u003ch4 align=\"center\"\u003eConfigured to be ready to be used for Log, Metrics, APM, Alerting, Machine Learning, and Security (SIEM) usecases.\u003c/h4\u003e\n\u003cp align=\"center\"\u003e\n   \u003ca\u003e\n      \u003cimg src=\"https://img.shields.io/badge/Elastic%20Stack-8.10.2-blue?style=flat\u0026logo=elasticsearch\" alt=\"Elastic Stack Version 7^^\"\u003e\n   \u003c/a\u003e\n   \u003ca\u003e\n      \u003cimg src=\"https://img.shields.io/github/v/tag/sherifabdlnaby/elastdocker?label=release\u0026amp;sort=semver\"\u003e\n   \u003c/a\u003e\n   \u003ca href=\"https://github.com/sherifabdlnaby/elastdocker/actions/workflows/build.yml\"\u003e\n      \u003cimg src=\"https://github.com/sherifabdlnaby/elastdocker/actions/workflows/build.yml/badge.svg\"\u003e\n   \u003c/a\u003e\n   \u003ca\u003e\n      \u003cimg src=\"https://img.shields.io/badge/Log4Shell-mitigated-brightgreen?style=flat\u0026logo=java\"\u003e\n   \u003c/a\u003e\n   \u003ca\u003e\n      \u003cimg src=\"https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat\" alt=\"contributions welcome\"\u003e\n   \u003c/a\u003e\n   \u003ca href=\"https://github.com/sherifabdlnaby/elastdocker/network\"\u003e\n      \u003cimg src=\"https://img.shields.io/github/forks/sherifabdlnaby/elastdocker.svg\" alt=\"GitHub forks\"\u003e\n   \u003c/a\u003e\n   \u003ca href=\"https://github.com/sherifabdlnaby/elastdocker/issues\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/issues/sherifabdlnaby/elastdocker.svg\" alt=\"GitHub issues\"\u003e\n   \u003c/a\u003e\n   \u003ca href=\"https://raw.githubusercontent.com/sherifabdlnaby/elastdocker/blob/master/LICENSE\"\u003e\n      \u003cimg src=\"https://img.shields.io/badge/license-MIT-blue.svg\" alt=\"GitHub license\"\u003e\n   \u003c/a\u003e\n\u003c/p\u003e\n\n# Introduction\nElastic Stack (**ELK**) Docker Composition, preconfigured with **Security**, **Monitoring**, and **Tools**; Up with a Single Command.\n\nSuitable for Demoing, MVPs and small production deployments.\n\nStack Version: [8.10.2](https://www.elastic.co/blog/whats-new-elastic-8-10-0) 🎉  - Based on [Official Elastic Docker Images](https://www.docker.elastic.co/)\n\u003e You can change Elastic Stack version by setting `ELK_VERSION` in `.env` file and rebuild your images. Any version \u003e= 8.0.0 is compatible with this template.\n\n### Main Features 📜\n\n- Configured as a Production Single Node Cluster. (With a multi-node cluster option for experimenting).\n- Security Enabled By Default.\n- Configured to Enable:\n  - Logging \u0026 Metrics Ingestion\n    - Option to collect logs of all Docker Containers running on the host. via `make collect-docker-logs`.\n  - APM\n  - Alerting\n  - Machine Learning\n  - Anomaly Detection\n  - SIEM (Security information and event management).\n  - Enabling Trial License\n- Use Docker-Compose and `.env` to configure your entire stack parameters.\n- Persist Elasticsearch's Keystore and SSL Certifications.\n- Self-Monitoring Metrics Enabled.\n- Prometheus Exporters for Stack Metrics.\n- Embedded Container Healthchecks for Stack Images.\n\n#### More points\nAnd comparing Elastdocker and the popular [deviantony/docker-elk](https://github.com/deviantony/docker-elk)\n\n\u003cdetails\u003e\u003csummary\u003eExpand...\u003c/summary\u003e\n\u003cp\u003e\n\nOne of the most popular ELK on Docker repositories is the awesome [deviantony/docker-elk](https://github.com/deviantony/docker-elk).\nElastdocker differs from `deviantony/docker-elk` in the following points.\n\n- Security enabled by default using Basic license, not Trial.\n\n- Persisting data by default in a volume.\n\n- Run in Production Mode (by enabling SSL on Transport Layer, and add initial master node settings).\n\n- Persisting Generated Keystore, and create an extendable script that makes it easier to recreate it every-time the container is created.\n\n- Parameterize credentials in .env instead of hardcoding `elastich:changeme` in every component config.\n\n- Parameterize all other Config like Heap Size.\n\n- Add recommended environment configurations as Ulimits and Swap disable to the docker-compose.\n\n- Make it ready to be extended into a multinode cluster.\n\n- 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).\n\n- Configured Prometheus Exporters.\n\n- The Makefile that simplifies everything into some simple commands.\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n-----\n\n# Requirements\n\n- [Docker 20.05 or higher](https://docs.docker.com/install/)\n- [Docker-Compose 1.29 or higher](https://docs.docker.com/compose/install/)\n- 4GB RAM (For Windows and MacOS make sure Docker's VM has more than 4GB+ memory.)\n\n# Setup\n\n1. Clone the Repository\n     ```bash\n     git clone https://github.com/sherifabdlnaby/elastdocker.git\n     ```\n2. Initialize Elasticsearch Keystore and TLS Self-Signed Certificates\n    ```bash\n    $ make setup\n    ```\n    \u003e **For Linux's docker hosts only**. By default virtual memory [is not enough](https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html) so run the next command as root `sysctl -w vm.max_map_count=262144`\n3. Start Elastic Stack\n    ```bash\n    $ make elk           \u003cOR\u003e         $ docker-compose up -d\t\t\u003cOR\u003e\t\t$ docker compose up -d\n    ```\n4. Visit Kibana at [https://localhost:5601](https://localhost:5601) or `https://\u003cyour_public_ip\u003e:5601`\n\n    Default Username: `elastic`, Password: `changeme`\n\n    \u003e - Notice that Kibana is configured to use HTTPS, so you'll need to write `https://` before `localhost:5601` in the browser.\n    \u003e - Modify `.env` file for your needs, most importantly `ELASTIC_PASSWORD` that setup your superuser `elastic`'s password, `ELASTICSEARCH_HEAP` \u0026 `LOGSTASH_HEAP` for Elasticsearch \u0026 Logstash Heap Size.\n    \n\u003e 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. \n\n\u003e 🏃🏻‍♂️ To start ingesting logs, you can start by running `make collect-docker-logs` which will collect your host's container logs.\n\n## Additional Commands\n\n\u003cdetails\u003e\u003csummary\u003eExpand\u003c/summary\u003e\n\u003cp\u003e\n\n#### To Start Monitoring and Prometheus Exporters\n```shell\n$ make monitoring\n```\n#### To Ship Docker Container Logs to ELK \n```shell\n$ make collect-docker-logs\n```\n#### To Start **Elastic Stack, Tools and Monitoring**\n```\n$ make all\n```\n#### To Start 2 Extra Elasticsearch nodes (recommended for experimenting only)\n```shell\n$ make nodes\n```\n#### To Rebuild Images\n```shell\n$ make build\n```\n#### Bring down the stack.\n```shell\n$ make down\n```\n\n#### Reset everything, Remove all containers, and delete **DATA**!\n```shell\n$ make prune\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n# Configuration\n\n* Some Configuration are parameterized in the `.env` file.\n  * `ELASTIC_PASSWORD`, user `elastic`'s password (default: `changeme` _pls_).\n  * `ELK_VERSION` Elastic Stack Version (default: `8.10.2`)\n  * `ELASTICSEARCH_HEAP`, how much Elasticsearch allocate from memory (default: 1GB -good for development only-)\n  * `LOGSTASH_HEAP`, how much Logstash allocate from memory.\n  * Other configurations which their such as cluster name, and node name, etc.\n* Elasticsearch Configuration in `elasticsearch.yml` at `./elasticsearch/config`.\n* Logstash Configuration in `logstash.yml` at `./logstash/config/logstash.yml`.\n* Logstash Pipeline in `main.conf` at `./logstash/pipeline/main.conf`.\n* Kibana Configuration in `kibana.yml` at `./kibana/config`.\n\n### Setting Up Keystore\n\nYou can extend the Keystore generation script by adding keys to `./setup/keystore.sh` script. (e.g Add S3 Snapshot Repository Credentials)\n\nTo Re-generate Keystore:\n```\nmake keystore\n```\n\n### Notes\n\n\n- ⚠️ 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`).\n\n- Adding Two Extra Nodes to the cluster will make the cluster depending on them and won't start without them again.\n\n- Makefile is a wrapper around `Docker-Compose` commands, use `make help` to know every command.\n\n- Elasticsearch will save its data to a volume named `elasticsearch-data`\n\n- Elasticsearch Keystore (that contains passwords and credentials) and SSL Certificate are generated in the `./secrets` directory by the setup command.\n\n- Make sure to run `make setup` if you changed `ELASTIC_PASSWORD` and to restart the stack afterwards.\n\n- For Linux Users it's recommended to set the following configuration (run as `root`)\n    ```\n    sysctl -w vm.max_map_count=262144\n    ```\n    By default, Virtual Memory [is not enough](https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html).\n\n---------------------------\n\n![Intro](https://user-images.githubusercontent.com/16992394/156664447-c24c49f4-4282-4d6a-81a7-10743cfa384e.png)\n![Alerting](https://user-images.githubusercontent.com/16992394/156664848-d14f5e58-8f80-497d-a841-914c05a4b69c.png)\n![Maps](https://user-images.githubusercontent.com/16992394/156664562-d38e11ee-b033-4b91-80bd-3a866ad65f56.png)\n![ML](https://user-images.githubusercontent.com/16992394/156664695-5c1ed4a7-82f3-47a6-ab5c-b0ce41cc0fbe.png)\n\n# Working with Elastic APM\n\nAfter 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.\n\n## Authenticating with Elastic APM\n\nIn order to authenticate with Elastic APM, you will need the following:\n\n- The value of `ELASTIC_APM_SECRET_TOKEN` defined in `.env` file as we have [secret token](https://www.elastic.co/guide/en/apm/guide/master/secret-token.html) enabled by default\n- The ability to reach port `8200`\n- Install elastic apm client in your application e.g. for NodeJS based applications you need to install [elastic-apm-node](https://www.elastic.co/guide/en/apm/agent/nodejs/master/typescript.html)\n- Import the package in your application and call the start function, In case of NodeJS based application you can do the following:\n\n```\nconst apm = require('elastic-apm-node').start({\n  serviceName: 'foobar',\n  secretToken: process.env.ELASTIC_APM_SECRET_TOKEN,\n  \n  // https is enabled by default as per elastdocker configuration\n  serverUrl: 'https://localhost:8200',\n})\n```\n\u003e 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](https://www.elastic.co/guide/en/apm/agent/nodejs/master/express.html#express-initialization)\n\nFor more details or other languages you can check the following:\n- [APM Agents in different languages](https://www.elastic.co/guide/en/apm/agent/index.html)\n\n# Monitoring The Cluster\n\n### Via Self-Monitoring\n\nHead to Stack Monitoring tab in Kibana to see cluster metrics for all stack components.\n\n![Overview](https://user-images.githubusercontent.com/16992394/156664539-cc7e1a69-f1aa-4aca-93f6-7aedaabedd2c.png)\n![Moniroting](https://user-images.githubusercontent.com/16992394/156664647-78cfe2af-489d-4c35-8963-9b0a46904cf7.png)\n\n\u003e In Production, cluster metrics should be shipped to another dedicated monitoring cluster.\n\n### Via Prometheus Exporters\nIf you started Prometheus Exporters using `make monitoring` command. Prometheus Exporters will expose metrics at the following ports.\n\n| **Prometheus Exporter**      | **Port**     | **Recommended Grafana Dashboard**                                         |\n|--------------------------    |----------    |------------------------------------------------  |\n| `elasticsearch-exporter`     | `9114`       | [Elasticsearch by Kristian Jensen](https://grafana.com/grafana/dashboards/4358)                                                |\n| `logstash-exporter`          | `9304`       | [logstash-monitoring by dpavlos](https://github.com/dpavlos/logstash-monitoring)                                               |\n\n![Metrics](https://user-images.githubusercontent.com/16992394/78685076-89a58900-78f1-11ea-959b-ce374fe51500.jpg)\n\n# License\n[MIT License](https://raw.githubusercontent.com/sherifabdlnaby/elastdocker/master/LICENSE)\nCopyright (c) 2022 Sherif Abdel-Naby\n\n# Contribution\n\nPR(s) are Open and Welcomed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsherifabdlnaby%2Felastdocker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsherifabdlnaby%2Felastdocker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsherifabdlnaby%2Felastdocker/lists"}