{"id":13614018,"url":"https://github.com/satishbabariya/elastic-stack-docker","last_synced_at":"2025-04-15T19:00:04.707Z","repository":{"id":99301862,"uuid":"239312406","full_name":"satishbabariya/elastic-stack-docker","owner":"satishbabariya","description":"Elastic stack (ELK) on Docker (APM, Logging, Elasticsearch, Kibana, Beats)","archived":false,"fork":false,"pushed_at":"2020-10-05T06:27:23.000Z","size":32,"stargazers_count":7,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T18:59:55.911Z","etag":null,"topics":["apm","docker","docker-compose","elasticsearch","elk","kibana","log","logstash"],"latest_commit_sha":null,"homepage":null,"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/satishbabariya.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-02-09T13:50:31.000Z","updated_at":"2023-01-15T18:44:48.000Z","dependencies_parsed_at":"2023-04-25T06:34:40.299Z","dependency_job_id":null,"html_url":"https://github.com/satishbabariya/elastic-stack-docker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satishbabariya%2Felastic-stack-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satishbabariya%2Felastic-stack-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satishbabariya%2Felastic-stack-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satishbabariya%2Felastic-stack-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/satishbabariya","download_url":"https://codeload.github.com/satishbabariya/elastic-stack-docker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249135822,"owners_count":21218365,"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":["apm","docker","docker-compose","elasticsearch","elk","kibana","log","logstash"],"created_at":"2024-08-01T20:00:55.879Z","updated_at":"2025-04-15T19:00:04.686Z","avatar_url":"https://github.com/satishbabariya.png","language":"Dockerfile","funding_links":[],"categories":["Dockerfile"],"sub_categories":[],"readme":"# Elastic stack (ELK) on Docker\n\nElastic stack (ELK) on Docker (APM, Logging, Elasticsearch, Kibana, Beats)\n\nRun the latest version of the [Elastic stack][elk-stack] with Docker and Docker Compose.\n\n## Contents\n\n1. [Requirements](#requirements)\n   - [Host setup](#host-setup)\n   - [SELinux](#selinux)\n   - [Docker for Desktop](#docker-for-desktop)\n     - [Windows](#windows)\n     - [macOS](#macos)\n2. [Usage](#usage)\n   - [Bringing up the stack](#bringing-up-the-stack)\n   - [Cleanup](#cleanup)\n   - [Initial setup](#initial-setup)\n     - [Setting up user authentication](#setting-up-user-authentication)\n     - [Injecting data](#injecting-data)\n     - [Default Kibana index pattern creation](#default-kibana-index-pattern-creation)\n3. [Configuration](#configuration)\n   - [How to configure Elasticsearch](#how-to-configure-elasticsearch)\n   - [How to configure Kibana](#how-to-configure-kibana)\n   - [How to configure Logstash](#how-to-configure-logstash)\n   - [How to disable paid features](#how-to-disable-paid-features)\n   - [How to scale out the Elasticsearch cluster](#how-to-scale-out-the-elasticsearch-cluster)\n4. [Extensibility](#extensibility)\n   - [How to add plugins](#how-to-add-plugins)\n   - [How to enable the provided extensions](#how-to-enable-the-provided-extensions)\n5. [JVM tuning](#jvm-tuning)\n   - [How to specify the amount of memory used by a service](#how-to-specify-the-amount-of-memory-used-by-a-service)\n   - [How to enable a remote JMX connection to a service](#how-to-enable-a-remote-jmx-connection-to-a-service)\n6. [Going further](#going-further)\n   - [Using a newer stack version](#using-a-newer-stack-version)\n   - [Plugins and integrations](#plugins-and-integrations)\n   - [Swarm mode](#swarm-mode)\n\n## Requirements\n\n### Host setup\n\n- [Docker Engine](https://docs.docker.com/install/) version **17.05+**\n- [Docker Compose](https://docs.docker.com/compose/install/) version **1.12.0+**\n- 1.5 GB of RAM\n\nBy default, the stack exposes the following ports:\n\n- 5000: Logstash TCP input\n- 9200: Elasticsearch HTTP\n- 9300: Elasticsearch TCP transport\n- 5601: Kibana\n\n\u003e :information_source: Elasticsearch's [bootstrap checks][booststap-checks] were purposely disabled to facilitate the\n\u003e setup of the Elastic stack in development environments. For production setups, we recommend users to set up their host\n\u003e according to the instructions from the Elasticsearch documentation: [Important System Configuration][es-sys-config].\n\n### SELinux\n\nOn distributions which have SELinux enabled out-of-the-box you will need to either re-context the files or set SELinux\ninto Permissive mode in order for docker-elk to start properly. For example on Redhat and CentOS, the following will\napply the proper context:\n\n```console\n$ chcon -R system_u:object_r:admin_home_t:s0 docker-elk/\n```\n\n### Docker for Desktop\n\n#### Windows\n\nEnsure the [Shared Drives][win-shareddrives] feature is enabled for the `C:` drive.\n\n#### macOS\n\nThe default Docker for Mac configuration allows mounting files from `/Users/`, `/Volumes/`, `/private/`, and `/tmp`\nexclusively. Make sure the repository is cloned in one of those locations or follow the instructions from the\n[documentation][mac-mounts] to add more locations.\n\n## Usage\n\n### Bringing up the stack\n\nClone this repository onto the Docker host that will run the stack, then start services locally using Docker Compose:\n\n```console\n$ docker-compose up\n```\n\nYou can also run all services in the background (detached mode) by adding the `-d` flag to the above command.\n\n\u003e :information_source: You must run `docker-compose build` first whenever you switch branch or update a base image.\n\nIf you are starting the stack for the very first time, please read the section below attentively.\n\n### Cleanup\n\nElasticsearch data is persisted inside a volume by default.\n\nIn order to entirely shutdown the stack and remove all persisted data, use the following Docker Compose command:\n\n```console\n$ docker-compose down -v\n```\n\n## Initial setup\n\n### Setting up user authentication\n\n\u003e :information_source: Refer to [How to disable paid features](#how-to-disable-paid-features) to disable authentication.\n\nThe stack is pre-configured with the following **privileged** bootstrap user:\n\n- user: _elastic_\n- password: _changeme_\n\nAlthough all stack components work out-of-the-box with this user, we strongly recommend using the unprivileged [built-in\nusers][builtin-users] instead for increased security.\n\n1. Initialize passwords for built-in users\n\n```console\n$ docker-compose exec -T elasticsearch bin/elasticsearch-setup-passwords auto --batch\n```\n\nPasswords for all 6 built-in users will be randomly generated. Take note of them.\n\n2. Unset the bootstrap password (_optional_)\n\nRemove the `ELASTIC_PASSWORD` environment variable from the `elasticsearch` service inside the Compose file\n(`docker-compose.yml`). It is only used to initialize the keystore during the initial startup of Elasticsearch.\n\n3. Replace usernames and passwords in configuration files\n\nUse the `kibana` user inside the Kibana configuration file (`kibana/config/kibana.yml`) and the `logstash_system` user\ninside the Logstash configuration file (`logstash/config/logstash.yml`) in place of the existing `elastic` user.\n\nReplace the password for the `elastic` user inside the Logstash pipeline file (`logstash/pipeline/logstash.conf`).\n\n\u003e :information*source: Do not use the `logstash_system` user inside the Logstash \\_pipeline* file, it does not have\n\u003e sufficient permissions to create indices. Follow the instructions at [Configuring Security in Logstash][ls-security]\n\u003e to create a user with suitable roles.\n\nSee also the [Configuration](#configuration) section below.\n\n4. Restart Kibana and Logstash to apply changes\n\n```console\n$ docker-compose restart kibana logstash\n```\n\n\u003e :information_source: Learn more about the security of the Elastic stack at [Tutorial: Getting started with\n\u003e security][sec-tutorial].\n\n### Injecting data\n\nGive Kibana about a minute to initialize, then access the Kibana web UI by hitting\n[http://localhost:5601](http://localhost:5601) with a web browser and use the following default credentials to log in:\n\n- user: _elastic_\n- password: _\\\u003cyour generated elastic password\u003e_\n\nNow that the stack is running, you can go ahead and inject some log entries. The shipped Logstash configuration allows\nyou to send content via TCP:\n\n```console\n# Using BSD netcat (Debian, Ubuntu, MacOS system, ...)\n$ cat /path/to/logfile.log | nc -q0 localhost 5000\n```\n\n```console\n# Using GNU netcat (CentOS, Fedora, MacOS Homebrew, ...)\n$ cat /path/to/logfile.log | nc -c localhost 5000\n```\n\nYou can also load the sample data provided by your Kibana installation.\n\n### Default Kibana index pattern creation\n\nWhen Kibana launches for the first time, it is not configured with any index pattern.\n\n#### Via the Kibana web UI\n\n\u003e :information*source: You need to inject data into Logstash before being able to configure a Logstash index pattern via\n\u003e the Kibana web UI. Then all you have to do is hit the \\_Create* button.\n\nRefer to [Connect Kibana with Elasticsearch][connect-kibana] for detailed instructions about the index pattern\nconfiguration.\n\n#### On the command line\n\nCreate an index pattern via the Kibana API:\n\n```console\n$ curl -XPOST -D- 'http://localhost:5601/api/saved_objects/index-pattern' \\\n    -H 'Content-Type: application/json' \\\n    -H 'kbn-version: 7.5.1' \\\n    -u elastic:\u003cyour generated elastic password\u003e \\\n    -d '{\"attributes\":{\"title\":\"logstash-*\",\"timeFieldName\":\"@timestamp\"}}'\n```\n\nThe created pattern will automatically be marked as the default index pattern as soon as the Kibana UI is opened for the first time.\n\n## Configuration\n\n\u003e :information_source: Configuration is not dynamically reloaded, you will need to restart individual components after\n\u003e any configuration change.\n\n### How to configure Elasticsearch\n\nThe Elasticsearch configuration is stored in [`elasticsearch/config/elasticsearch.yml`][config-es].\n\nYou can also specify the options you want to override by setting environment variables inside the Compose file:\n\n```yml\nelasticsearch:\n  environment:\n    network.host: _non_loopback_\n    cluster.name: my-cluster\n```\n\nPlease refer to the following documentation page for more details about how to configure Elasticsearch inside Docker\ncontainers: [Install Elasticsearch with Docker][es-docker].\n\n### How to configure Kibana\n\nThe Kibana default configuration is stored in [`kibana/config/kibana.yml`][config-kbn].\n\nIt is also possible to map the entire `config` directory instead of a single file.\n\nPlease refer to the following documentation page for more details about how to configure Kibana inside Docker\ncontainers: [Running Kibana on Docker][kbn-docker].\n\n### How to configure Logstash\n\nThe Logstash configuration is stored in [`logstash/config/logstash.yml`][config-ls].\n\nIt is also possible to map the entire `config` directory instead of a single file, however you must be aware that\nLogstash will be expecting a [`log4j2.properties`][log4j-props] file for its own logging.\n\nPlease refer to the following documentation page for more details about how to configure Logstash inside Docker\ncontainers: [Configuring Logstash for Docker][ls-docker].\n\n### How to disable paid features\n\nSwitch the value of Elasticsearch's `xpack.license.self_generated.type` option from `trial` to `basic` (see [License\nsettings][trial-license]).\n\n## Extensibility\n\n### How to add plugins\n\nTo add plugins to any ELK component you have to:\n\n1. Add a `RUN` statement to the corresponding `Dockerfile` (eg. `RUN logstash-plugin install logstash-filter-json`)\n2. Add the associated plugin code configuration to the service configuration (eg. Logstash input/output)\n3. Rebuild the images using the `docker-compose build` command\n\n### How to enable the provided extensions\n\nA few extensions are available inside the [`extensions`](extensions) directory. These extensions provide features which\nare not part of the standard Elastic stack, but can be used to enrich it with extra integrations.\n\nThe documentation for these extensions is provided inside each individual subdirectory, on a per-extension basis. Some\nof them require manual changes to the default ELK configuration.\n\n## JVM tuning\n\n### How to specify the amount of memory used by a service\n\nBy default, both Elasticsearch and Logstash start with [1/4 of the total host\nmemory](https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/parallel.html#default_heap_size) allocated to\nthe JVM Heap Size.\n\nThe startup scripts for Elasticsearch and Logstash can append extra JVM options from the value of an environment\nvariable, allowing the user to adjust the amount of memory that can be used by each component:\n\n| Service       | Environment variable |\n| ------------- | -------------------- |\n| Elasticsearch | ES_JAVA_OPTS         |\n| Logstash      | LS_JAVA_OPTS         |\n\nTo accomodate environments where memory is scarce (Docker for Mac has only 2 GB available by default), the Heap Size\nallocation is capped by default to 256MB per service in the `docker-compose.yml` file. If you want to override the\ndefault JVM configuration, edit the matching environment variable(s) in the `docker-compose.yml` file.\n\nFor example, to increase the maximum JVM Heap Size for Logstash:\n\n```yml\nlogstash:\n  environment:\n    LS_JAVA_OPTS: -Xmx1g -Xms1g\n```\n\n### How to enable a remote JMX connection to a service\n\nAs for the Java Heap memory (see above), you can specify JVM options to enable JMX and map the JMX port on the Docker\nhost.\n\nUpdate the `{ES,LS}_JAVA_OPTS` environment variable with the following content (I've mapped the JMX service on the port\n18080, you can change that). Do not forget to update the `-Djava.rmi.server.hostname` option with the IP address of your\nDocker host (replace **DOCKER_HOST_IP**):\n\n```yml\nlogstash:\n  environment:\n    LS_JAVA_OPTS: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=18080 -Dcom.sun.management.jmxremote.rmi.port=18080 -Djava.rmi.server.hostname=DOCKER_HOST_IP -Dcom.sun.management.jmxremote.local.only=false\n```\n\n## Going further\n\n### Using a newer stack version\n\nTo use a different Elastic Stack version than the one currently available in the repository, simply change the version\nnumber inside the `.env` file, and rebuild the stack with:\n\n```console\n$ docker-compose build\n$ docker-compose up\n```\n\n\u003e :information_source: Always pay attention to the [upgrade instructions][upgrade] for each individual component before\n\u003e performing a stack upgrade.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsatishbabariya%2Felastic-stack-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsatishbabariya%2Felastic-stack-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsatishbabariya%2Felastic-stack-docker/lists"}