Skip to content

Commit

Permalink
Add docker config for elasticsearch and logstash
Browse files Browse the repository at this point in the history
Elasticsearch is the chosen DB to store wforce reports long-term.
Reports arrive via Logstash, using the UDP input. Logstash acts
as a NamedReportSink for wforce.
Kibana support in the Docker config is onoing due to issues with
performance on MacOS. Currently the kibana config stores the json
for a bunch of pre-configured views and dashboards for wforce data.
  • Loading branch information
neilcook committed Mar 16, 2017
1 parent 0250601 commit af4535c
Show file tree
Hide file tree
Showing 9 changed files with 492 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignore .docker file
/.docker
43 changes: 43 additions & 0 deletions docker/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
DCMP = docker-compose
COMPOSE_SOURCE = docker-compose.yml elasticsearch/Dockerfile logstash/Dockerfile logstash/config/logstash.conf
COMPOSE_TARGET = .docker
ES_DATA_DIR = elasticsearch/data-dir
GEOIP_FILENAME = GeoLite2-City.mmdb
GEOIP_FILE_GZ = logstash/geoip/$(GEOIP_FILENAME).gz
GEOIP_FILE = logstash/geoip/$(GEOIP_FILENAME)

$(GEOIP_FILE_GZ):
wget -N -O $(GEOIP_FILE_GZ) http://geolite.maxmind.com/download/geoip/database/$(GEOIP_FILENAME).gz

$(GEOIP_FILE): $(GEOIP_FILE_GZ)
gunzip -c $(GEOIP_FILE_GZ) >$(GEOIP_FILE)

$(COMPOSE_TARGET): $(COMPOSE_SOURCE) $(GEOIP_FILE)
$(DCMP) down
$(DCMP) build
touch $(COMPOSE_TARGET)

build_image: $(COMPOSE_TARGET)

start:
$(DCMP) up -d

stop:
$(DCMP) stop

kill:
$(DCMP) kill

clean_elastic: stop
rm -rf $(ES_DATA_DIR)/*
rm $(COMPOSE_TARGET)

clean_geoip:
rm -rf logstash/geoip/*

clean_docker:
docker-compose down

clean: clean_docker clean_geoip clean_elastic

all: build_image start
30 changes: 30 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: '2'
services:
logstash:
build: logstash
ports:
- "14501:4501/udp"
command: -f /etc/logstash/conf.d/
volumes:
- ./logstash/config:/etc/logstash/conf.d
- ./logstash/geoip:/etc/logstash/geoip
- ./logstash/templates:/tmp/templates
links:
- elasticsearch
depends_on:
- elasticsearch
networks:
- docker_elk
elasticsearch:
build: elasticsearch
volumes:
- ./elasticsearch/data-dir:/usr/share/elasticsearch/data
ports:
- "9200:9200"
- "9300:9300"
networks:
- docker_elk

networks:
docker_elk:
driver: bridge
3 changes: 3 additions & 0 deletions docker/elasticsearch/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM elasticsearch:5.2
ENV ES_JAVA_OPTS="-Des.path.conf=/etc/elasticsearch"
CMD ["-E", "network.host=_site_", "-E", "discovery.zen.minimum_master_nodes=1"]
2 changes: 2 additions & 0 deletions docker/elasticsearch/data-dir/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignore everything under this directory
/nodes
382 changes: 382 additions & 0 deletions docker/kibana/kibana_saved_objects.json

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions docker/logstash/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM logstash:5

RUN wget http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz
RUN gunzip GeoLite2-City.mmdb.gz
RUN mv GeoLite2-City.mmdb /etc/logstash/GeoLiteCity.dat

RUN logstash-plugin install logstash-input-udp
RUN logstash-plugin install logstash-output-elasticsearch
RUN logstash-plugin install logstash-filter-geoip
19 changes: 19 additions & 0 deletions docker/logstash/config/logstash.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
input {
udp {
port => 4501
codec => json
type => wforce_report
}
}
filter {
geoip {
database => "/etc/logstash/geoip/GeoLite2-City.mmdb"
source => "remote"
}
}
output {
elasticsearch {
hosts => "elasticsearch:9200"
index => "logstash-wforce-%{+YYYY.MM.dd}"
}
}
2 changes: 2 additions & 0 deletions docker/logstash/geoip/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignore GeoIP files
/*mmdb*

0 comments on commit af4535c

Please sign in to comment.