{"id":19005275,"url":"https://github.com/codeedu/elastic-stack-template","last_synced_at":"2025-04-22T18:54:21.020Z","repository":{"id":92091678,"uuid":"278475956","full_name":"codeedu/elastic-stack-template","owner":"codeedu","description":null,"archived":false,"fork":false,"pushed_at":"2020-07-09T21:36:49.000Z","size":16,"stargazers_count":17,"open_issues_count":0,"forks_count":9,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-17T10:26:16.089Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","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/codeedu.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-09T21:36:27.000Z","updated_at":"2025-01-29T03:14:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"1d41b4d3-15aa-4c48-9082-18db21669ca9","html_url":"https://github.com/codeedu/elastic-stack-template","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/codeedu%2Felastic-stack-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeedu%2Felastic-stack-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeedu%2Felastic-stack-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeedu%2Felastic-stack-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeedu","download_url":"https://codeload.github.com/codeedu/elastic-stack-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250305105,"owners_count":21408919,"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":[],"created_at":"2024-11-08T18:26:56.604Z","updated_at":"2025-04-22T18:54:20.990Z","avatar_url":"https://github.com/codeedu.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Elastic stack (ELK) on Docker\n\n[![Join the chat at https://gitter.im/deviantony/docker-elk](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/deviantony/docker-elk?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n[![Elastic Stack version](https://img.shields.io/badge/ELK-7.2.1-blue.svg?style=flat)](https://github.com/deviantony/docker-elk/issues/421)\n[![Build Status](https://api.travis-ci.org/deviantony/docker-elk.svg?branch=master)](https://travis-ci.org/deviantony/docker-elk)\n\nRun the latest version of the [Elastic stack][elk-stack] with Docker and Docker Compose.\n\nIt gives you the ability to analyze any data set by using the searching/aggregation capabilities of Elasticsearch and\nthe visualization power of Kibana.\n\n\u003e :information_source: The Docker images backing this stack include [Stack Features][stack-features] (formerly X-Pack)\nwith [paid features][paid-features] enabled by default (see [How to disable paid\nfeatures](#how-to-disable-paid-features) to disable them). The [trial license][trial-license] is valid for 30 days.\n\nBased on the official Docker images from Elastic:\n\n* [Elasticsearch](https://github.com/elastic/elasticsearch/tree/master/distribution/docker)\n* [Logstash](https://github.com/elastic/logstash/tree/master/docker)\n* [Kibana](https://github.com/elastic/kibana/tree/master/src/dev/build/tasks/os_packages/docker_generator)\n\nOther available stack variants:\n\n* [`searchguard`](https://github.com/deviantony/docker-elk/tree/searchguard): Search Guard support\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   * [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. [Storage](#storage)\n   * [How to persist Elasticsearch data](#how-to-persist-elasticsearch-data)\n5. [Extensibility](#extensibility)\n   * [How to add plugins](#how-to-add-plugins)\n   * [How to enable the provided extensions](#how-to-enable-the-provided-extensions)\n6. [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)\n7. [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](https://www.docker.com/community-edition#/download) version **17.05+**\n* [Docker Compose](https://docs.docker.com/compose/install/) version **1.6.0+**\n* 1.5 GB of RAM\n\nBy default, the stack exposes the following ports:\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, then start the stack 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## 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. Passwords for these users must be initialized:\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 and replace the `elastic` username with\n`kibana` and `logstash_system` inside the Kibana and Logstash configuration files respectively. See the\n[Configuration](#configuration) section below.\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\nRestart Kibana and Logstash to apply the passwords you just wrote to the configuration files.\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$ nc localhost 5000 \u003c /path/to/logfile.log\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\nthe 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.2.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\nany 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\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### How to scale out the Elasticsearch cluster\n\nFollow the instructions from the Wiki: [Scaling out Elasticsearch](https://github.com/deviantony/docker-elk/wiki/Elasticsearch-cluster)\n\n## Storage\n\n### How to persist Elasticsearch data\n\nThe data stored in Elasticsearch will be persisted after container reboot but not after container removal.\n\nIn order to persist Elasticsearch data even after removing the Elasticsearch container, you'll have to mount a volume on\nyour Docker host. Update the `elasticsearch` service declaration to:\n\n```yml\nelasticsearch:\n\n  volumes:\n    - /path/to/storage:/usr/share/elasticsearch/data\n```\n\nThis will store Elasticsearch data inside `/path/to/storage`.\n\n\u003e :information_source: (Linux users) Beware that the Elasticsearch process runs as the [unprivileged `elasticsearch`\nuser][esuser] is used within the Elasticsearch image, therefore the mounted data directory must be writable by the uid\n`1000`.\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\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\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\nperforming a stack upgrade.\n\n### Plugins and integrations\n\nSee the following Wiki pages:\n\n* [External applications](https://github.com/deviantony/docker-elk/wiki/External-applications)\n* [Popular integrations](https://github.com/deviantony/docker-elk/wiki/Popular-integrations)\n\n### Swarm mode\n\nExperimental support for Docker [Swarm mode][swarm-mode] is provided in the form of a `docker-stack.yml` file, which can\nbe deployed in an existing Swarm cluster using the following command:\n\n```console\n$ docker stack deploy -c docker-stack.yml elk\n```\n\nIf all components get deployed without any error, the following command will show 3 running services:\n\n```console\n$ docker stack services elk\n```\n\n\u003e :information_source: To scale Elasticsearch in Swarm mode, configure *zen* to use the DNS name `tasks.elasticsearch`\ninstead of `elasticsearch`.\n\n\n[elk-stack]: https://www.elastic.co/elk-stack\n[stack-features]: https://www.elastic.co/products/stack\n[paid-features]: https://www.elastic.co/subscriptions\n[trial-license]: https://www.elastic.co/guide/en/elasticsearch/reference/current/license-settings.html\n\n[booststap-checks]: https://www.elastic.co/guide/en/elasticsearch/reference/current/bootstrap-checks.html\n[es-sys-config]: https://www.elastic.co/guide/en/elasticsearch/reference/current/system-config.html\n\n[win-shareddrives]: https://docs.docker.com/docker-for-windows/#shared-drives\n[mac-mounts]: https://docs.docker.com/docker-for-mac/osxfs/\n\n[builtin-users]: https://www.elastic.co/guide/en/x-pack/current/setting-up-authentication.html#built-in-users\n[ls-security]: https://www.elastic.co/guide/en/logstash/current/ls-security.html\n[sec-tutorial]: https://www.elastic.co/guide/en/elastic-stack-overview/current/security-getting-started.html\n\n[connect-kibana]: https://www.elastic.co/guide/en/kibana/current/connect-to-elasticsearch.html\n\n[config-es]: ./elasticsearch/config/elasticsearch.yml\n[config-kbn]: ./kibana/config/kibana.yml\n[config-ls]: ./logstash/config/logstash.yml\n\n[es-docker]: https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html\n[kbn-docker]: https://www.elastic.co/guide/en/kibana/current/docker.html\n[ls-docker]: https://www.elastic.co/guide/en/logstash/current/docker-config.html\n\n[log4j-props]: https://github.com/elastic/logstash/tree/7.3/docker/data/logstash/config\n[esuser]: https://github.com/elastic/elasticsearch/blob/7.3/distribution/docker/src/docker/Dockerfile#L18-L19\n\n[upgrade]: https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-upgrade.html\n\n[swarm-mode]: https://docs.docker.com/engine/swarm/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeedu%2Felastic-stack-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeedu%2Felastic-stack-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeedu%2Felastic-stack-template/lists"}