@@ -19,12 +19,13 @@ services:
1919 #
2020 elasticsearch :
2121 image : docker.elastic.co/elasticsearch/elasticsearch:${TAG}
22- environment : ['http.host=0.0.0.0', 'transport.host=127.0.0.1']
22+ environment : ['http.host=0.0.0.0', 'transport.host=127.0.0.1', 'ELASTIC_PWD=${ELASTIC_PWD}' ]
2323 ports : ['127.0.0.1:9200:9200']
2424 networks : ['stack']
2525
2626 kibana :
2727 image : docker.elastic.co/kibana/kibana:${TAG}
28+ environment : ['ELASTICSEARCH_PASSWORD=${ELASTIC_PWD}']
2829 ports : ['127.0.0.1:5601:5601']
2930 networks : ['stack']
3031 depends_on : ['elasticsearch']
@@ -80,6 +81,30 @@ services:
8081 command : packetbeat -v -e -E output.elasticsearch.hosts='["localhost:9200"]'
8182 depends_on : ['elasticsearch']
8283
84+ # Run a short-lived container to import the default dashboards for the Beats.
85+ import_dashboards :
86+ # Any Beats image will do. We'll use Metricbeat.
87+ image : docker.elastic.co/beats/metricbeat:${TAG}
88+ networks : ['stack']
89+ command : >-
90+ /usr/share/metricbeat/scripts/import_dashboards
91+ -beat ""
92+ -file /usr/share/metricbeat/beats-dashboards-${ELASTIC_VERSION}.zip
93+ -es http://elasticsearch:9200
94+ -user elastic
95+ -pass ${ELASTIC_PWD}
96+ depends_on : ['kibana']
97+
98+ # Another short-lived container to create a Kibana index pattern for Logstash.
99+ create_logstash_index_pattern :
100+ # The image just needs curl, and we know that Metricbeat has that.
101+ image : docker.elastic.co/beats/metricbeat:${TAG}
102+ networks : ['stack']
103+ # There's currently no API for creating index patterns, so this is a bit hackish.
104+ command : >-
105+ curl -XPUT http://elastic:${ELASTIC_PWD}@elasticsearch:9200/.kibana/index-pattern/logstash-*
106+ -d '{"title" : "logstash-*", "timeFieldName": "@timestamp"}'
107+
83108 # Run a short-lived container to set up Kibana index patterns and dashboards.
84109 configure_kibana :
85110 # Any Beats image will suffice. We'll use Metricbeat.
@@ -91,5 +116,8 @@ services:
91116 environment : ['ELASTIC_VERSION=${ELASTIC_VERSION}']
92117 networks : ['stack']
93118 depends_on : ['kibana']
119+ command : >-
120+ curl -XPUT http://elastic:${ELASTIC_PWD}@elasticsearch:9200/.kibana/config/${SHORT_VERSION}
121+ -d '{"defaultIndex" : "metricbeat-*"}'
94122
95123networks : {stack: {}}
0 commit comments