From 890c3959e6f78363e987309ab8c31581b73b8cd6 Mon Sep 17 00:00:00 2001 From: Anthony Lapenna Date: Thu, 7 Jul 2016 10:08:50 +1200 Subject: [PATCH] allow logstash plugin management --- README.md | 30 +++++++++++++++++++++--------- docker-compose.yml | 2 +- logstash/Dockerfile | 4 ++++ logstash/config/logstash.conf | 2 +- 4 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 logstash/Dockerfile diff --git a/README.md b/README.md index a841c5f..4fd4fa9 100644 --- a/README.md +++ b/README.md @@ -67,8 +67,7 @@ And then access Kibana UI by hitting [http://localhost:5601](http://localhost:56 * user: *elastic* * password: *changeme* -*NOTE*: You'll need to inject data into logstash before being able to create a logstash index in Kibana. Then all you should have to do is to -hit the create button. +*NOTE*: You'll need to inject data into logstash before being able to create a logstash index in Kibana. Then all you should have to do is to hit the create button. See: https://www.elastic.co/guide/en/kibana/current/setup.html#connect @@ -105,8 +104,8 @@ If you want to override the default configuration, add the *LS_HEAP_SIZE* enviro ```yml logstash: - image: logstash:latest - command: logstash -f /etc/logstash/conf.d/logstash.conf + build: logstash/ + command: -f /etc/logstash/conf.d/ volumes: - ./logstash/config:/etc/logstash/conf.d ports: @@ -117,6 +116,13 @@ logstash: - LS_HEAP_SIZE=2048m ``` +## How can I add Logstash plugins? ## + +To add plugins to logstash you have to: + +1. Add a RUN statement to the `logstash/Dockerfile` (ex. `RUN logstash-plugin install logstash-filter-json`) +2. Add the associated plugin code configuration to the `logstash/config/logstash.conf` file + ## How can I enable a remote JMX connection to Logstash? As for the Java heap memory, another environment variable allows to specify JAVA_OPTS used by Logstash. You'll need to specify the appropriate options to enable JMX and map the JMX port on the docker host. @@ -125,13 +131,12 @@ Update the container in the `docker-compose.yml` to add the *LS_JAVA_OPTS* envir ```yml logstash: - image: logstash:latest - command: logstash -f /etc/logstash/conf.d/logstash.conf + build: logstash/ + command: -f /etc/logstash/conf.d/ volumes: - ./logstash/config:/etc/logstash/conf.d ports: - "5000:5000" - - "18080:18080" links: - elasticsearch environment: @@ -149,9 +154,11 @@ Then, you'll need to map your configuration file inside the container in the `do ```yml elasticsearch: build: elasticsearch/ - command: elasticsearch -Des.network.host=_non_loopback_ ports: - "9200:9200" + - "9300:9300" + environment: + ES_JAVA_OPTS: "-Xms1g -Xmx1g" volumes: - ./elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml ``` @@ -164,6 +171,9 @@ elasticsearch: command: elasticsearch -Des.network.host=_non_loopback_ -Des.cluster.name: my-cluster ports: - "9200:9200" + - "9300:9300" + environment: + ES_JAVA_OPTS: "-Xms1g -Xmx1g" ``` # Storage @@ -177,9 +187,11 @@ In order to persist Elasticsearch data even after removing the Elasticsearch con ```yml elasticsearch: build: elasticsearch/ - command: elasticsearch -Des.network.host=_non_loopback_ ports: - "9200:9200" + - "9300:9300" + environment: + ES_JAVA_OPTS: "-Xms1g -Xmx1g" volumes: - /path/to/storage:/usr/share/elasticsearch/data ``` diff --git a/docker-compose.yml b/docker-compose.yml index 15d70a0..62e1946 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ elasticsearch: environment: ES_JAVA_OPTS: "-Xms1g -Xmx1g" logstash: - image: logstash:5 + build: logstash/ command: -f /etc/logstash/conf.d/ volumes: - ./logstash/config:/etc/logstash/conf.d diff --git a/logstash/Dockerfile b/logstash/Dockerfile new file mode 100644 index 0000000..0bb7979 --- /dev/null +++ b/logstash/Dockerfile @@ -0,0 +1,4 @@ +FROM logstash:latest + +# Add your logstash plugins setup here +# Example: RUN logstash-plugin install logstash-filter-json diff --git a/logstash/config/logstash.conf b/logstash/config/logstash.conf index 2cc24b4..14c76f8 100644 --- a/logstash/config/logstash.conf +++ b/logstash/config/logstash.conf @@ -4,7 +4,7 @@ input { } } -## Add your filters here +## Add your filters / logstash plugins configuration here output { elasticsearch {