{"id":18454747,"url":"https://github.com/ossec/kofe-docker","last_synced_at":"2025-04-08T04:33:49.194Z","repository":{"id":49772670,"uuid":"363749219","full_name":"ossec/kofe-docker","owner":"ossec","description":"KOFE (Kibana, OSSEC, Filebeat, and Elasticsearch) using Docker","archived":false,"fork":false,"pushed_at":"2022-11-16T23:32:49.000Z","size":22,"stargazers_count":7,"open_issues_count":3,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-23T06:11:20.151Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ossec.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-02T21:02:05.000Z","updated_at":"2024-11-15T09:53:29.000Z","dependencies_parsed_at":"2023-01-21T20:35:38.714Z","dependency_job_id":null,"html_url":"https://github.com/ossec/kofe-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/ossec%2Fkofe-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ossec%2Fkofe-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ossec%2Fkofe-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ossec%2Fkofe-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ossec","download_url":"https://codeload.github.com/ossec/kofe-docker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247779796,"owners_count":20994569,"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-06T08:05:59.419Z","updated_at":"2025-04-08T04:33:48.786Z","avatar_url":"https://github.com/ossec.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Elastic stack (ELK) on Docker\n\n[![Elastic Stack version](https://img.shields.io/badge/Elastic%20Stack-7.11.2-00bfb3?style=flat\u0026logo=elastic-stack)](https://www.elastic.co/blog/category/releases)\n[![Build Status](https://github.com/deviantony/docker-elk/workflows/CI/badge.svg?branch=main)](https://github.com/deviantony/docker-elk/actions?query=workflow%3ACI+branch%3Amain)\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\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*:information_source: The Docker images backing this stack include [X-Pack][xpack] with [paid features][paid-features]\nenabled by default (see [How to disable paid features](#how-to-disable-paid-features) to disable them). **The [trial\nlicense][trial-license] is valid for 30 days**. After this license expires, you can continue using the free features\nseamlessly, without losing any data.*\n\nBased on the official Docker images from Elastic:\n\n* [Elasticsearch](https://github.com/elastic/elasticsearch/tree/master/distribution/docker)\n* [Filebeat](https://github.com/elastic/beats/tree/master/filebeat)\n* [Kibana](https://github.com/elastic/kibana/tree/master/src/dev/build/tasks/os_packages/docker_generator)\n\n---\n\n## Philosophy\n\nKOFE (Kibana, OSSEC, Filebeat, and Elasticsearch) project's sole purpose is to provide a simple solution into the\nimplementation of OSSEC while providing visualization of OSSEC alerts via Kibana.\n---\n\n## Contents\n\n1. [Requirements](#requirements)\n\t * [Host setup](#host-setup)\n\t * [SELinux](#selinux)\n\t * [Docker for Desktop](#docker-for-desktop)\n\t\t * [Windows](#windows)\n\t\t * [macOS](#macos)\n1. [Usage](#usage)\n\t * [Version selection](#version-selection)\n\t * [Bringing up the stack](#bringing-up-the-stack)\n\t * [Cleanup](#cleanup)\n\t * [Initial setup](#initial-setup)\n\t\t * [Setting up user authentication](#setting-up-user-authentication)\n\t\t * [Injecting data](#injecting-data)\n\t\t * [Default Kibana index pattern creation](#default-kibana-index-pattern-creation)\n1. [Configuration](#configuration)\n\t * [How to configure Elasticsearch](#how-to-configure-elasticsearch)\n\t * [How to configure Kibana](#how-to-configure-kibana)\n\t * [How to configure Logstash](#how-to-configure-logstash)\n\t * [How to disable paid features](#how-to-disable-paid-features)\n\t * [How to scale out the Elasticsearch cluster](#how-to-scale-out-the-elasticsearch-cluster)\n\t * [How to reset a password programmatically](#how-to-reset-a-password-programmatically)\n1. [JVM tuning](#jvm-tuning)\n\t * [How to specify the amount of memory used by a service](#how-to-specify-the-amount-of-memory-used-by-a-service)\n\t * [How to enable a remote JMX connection to a service](#how-to-enable-a-remote-jmx-connection-to-a-service)\n\n## Requirements\n\n### Host setup\n\n* [Docker Engine](https://docs.docker.com/install/) version **17.05** or newer\n* [Docker Compose](https://docs.docker.com/compose/install/) version **1.20.0** or newer\n* 1.5 GB of RAM\n\n*:information_source: Especially on Linux, make sure your user has the [required permissions][linux-postinstall] to\ninteract with the Docker daemon.*\n\nBy default, the stack exposes the following ports:\n\n* 9200: Elasticsearch HTTP\n* 9300: Elasticsearch TCP transport\n* 5601: Kibana\n* 1515: OSSEC Authd Registration port\n* 1514: OSSEC Remoted Communications port\n\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### Version selection\n\nThis repository tries to stay aligned with the latest version of the Elastic stack. The `main` branch tracks the current\nmajor version (7.x).\n\nTo use a different version of the core Elastic components, simply change the version number inside the `.env` file. If\nyou are upgrading an existing stack, please carefully read the note in the next section.\n\n**:warning: Always pay attention to the [official upgrade instructions][upgrade] for each individual component before\nperforming a stack upgrade.**\n\nOlder major versions are also supported on separate branches:\n\n* [`release-6.x`](https://github.com/deviantony/docker-elk/tree/release-6.x): 6.x series\n* [`release-5.x`](https://github.com/deviantony/docker-elk/tree/release-5.x): 5.x series (End-Of-Life)\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$ make create\n```\n\nYou can also run all services in the background (detached mode) by adding the `-d` flag to the above command.\n\n**:warning: You must rebuild the stack images with `docker-compose build` whenever you switch branch or update the\nversion of an already existing stack.**\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$ make destroy\n```\n\n## Initial setup\n\n### Setting up user authentication\n\n*: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\t\t```console\n\t\t$ docker-compose exec -T elasticsearch bin/elasticsearch-setup-passwords auto --batch\n\t\t```\n\n\t\tPasswords for all 6 built-in users will be randomly generated. Take note of them.\n\n1. Unset the bootstrap password (_optional_)\n\n\t\tRemove the `ELASTIC_PASSWORD` environment variable from the `elasticsearch` service inside the Compose file\n\t\t(`docker-compose.yml`). It is only used to initialize the keystore during the initial startup of Elasticsearch.\n\n1. Replace usernames and passwords in configuration files\n\n\t\tUse the `kibana_system` user (`kibana` for releases \u003c7.8.0) inside the Kibana configuration file\n\t\t(`kibana/config/kibana.yml`) and the `logstash_system` user inside the Logstash configuration file\n\t\t(`logstash/config/logstash.yml`) in place of the existing `elastic` user.\n\n\t\tReplace the password for the `elastic` user inside the Logstash pipeline file (`logstash/pipeline/logstash.conf`).\n\n\t\t*:information_source: Do not use the `logstash_system` user inside the Logstash **pipeline** file, it does not have\n\t\tsufficient permissions to create indices. Follow the instructions at [Configuring Security in Logstash][ls-security]\n\t\tto create a user with suitable roles.*\n\n\t\tSee also the [Configuration](#configuration) section below.\n\n1. Restart Kibana and Logstash to apply changes\n\n\t\t```console\n\t\t$ docker-compose restart kibana logstash\n\t\t```\n\n\t\t*:information_source: Learn more about the security of the Elastic stack at [Tutorial: Getting started with\n\t\tsecurity][sec-tutorial].*\n\n### Injecting data\n\nGive Kibana about a minute to initialize, then access the Kibana web UI by opening \u003chttp://localhost:5601\u003e in a web\nbrowser and use the following 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*:information_source: You need to inject data into Logstash before being able to configure a Logstash index pattern via\nthe Kibana web UI.*\n\nNavigate to the _Discover_ view of Kibana from the left sidebar. You will be prompted to create an index pattern. Enter\n`ossec-*` to match Logstash indices then, on the next page, select `@timestamp` as the time filter field. Finally,\nclick _Create index pattern_ and return to the _Discover_ view to inspect your log entries.\n\nRefer to [Connect Kibana with Elasticsearch][connect-kibana] and [Creating an index pattern][index-pattern] for detailed\ninstructions about the index pattern configuration.\n\n#### On the command line\n\nGenerate OSSEC index using Kibana API.\n\n```console\n$ make generate-index\n```\n\nNote: There will be a prompt to supply your **Elasticsearch Password**.\n\nThe created pattern will automatically be marked as the default index pattern as soon as the Kibana UI is opened for the\nfirst time.\n\n**Expected Output**\n```console\n$ make generate-index\n$ /root/kofe-docker/scripts/index-manage.sh\n$ Enter Elasticsearch Password: [REDACTED]\n$ OSSEC index generated!\n```\n\n\n## Configuration\n\n*: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\tenvironment:\n\t\tnetwork.host: _non_loopback_\n\t\tcluster.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: [Install Kibana with Docker][kbn-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 reset a password programmatically\n\nIf for any reason your are unable to use Kibana to change the password of your users (including [built-in\nusers][builtin-users]), you can use the Elasticsearch API instead and achieve the same result.\n\nIn the example below, we reset the password of the `elastic` user (notice \"/user/elastic\" in the URL):\n\n```console\n$ curl -XPOST -D- 'http://localhost:9200/_security/user/elastic/_password' \\\n\t\t-H 'Content-Type: application/json' \\\n\t\t-u elastic:\u003cyour current elastic password\u003e \\\n\t\t-d '{\"password\" : \"\u003cyour new password\u003e\"}'\n```\n\n## JVM tuning\n\n### How to specify the amount of memory used by a service\n\nBy default, Elasticsearch starts 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 script for Elasticsearch 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\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\nelasticsearch:\n\n\tenvironment:\n\t\tES_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\nelasticsearch:\n\n\tenvironment:\n\t\tES_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## Coming Soon!\n* TLS support for Elasticsearch and Kibana\n\n\n## Thanks\nSpecial thanks to:\n\n* The creators of [docker-elk](https://github.com/deviantony/docker-elk)\n* Scott Shinn for creating [ossec-docker](https://github/ossec/ossec-docker)\n\n[elk-stack]: https://www.elastic.co/what-is/elk-stack\n[xpack]: https://www.elastic.co/what-is/open-x-pack\n[paid-features]: https://www.elastic.co/subscriptions\n[trial-license]: https://www.elastic.co/guide/en/elasticsearch/reference/current/license-settings.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fossec%2Fkofe-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fossec%2Fkofe-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fossec%2Fkofe-docker/lists"}