Skip to content

Commit ea38996

Browse files
author
Toby McLaughlin
committed
Port to docker-compose 3.2
1 parent b808384 commit ea38996

2 files changed

Lines changed: 42 additions & 48 deletions

File tree

docker-compose.yml

Lines changed: 18 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
version: '2.1'
2+
version: '3.2'
33
services:
44
# The environment variable "TAG" is used throughout this file to
55
# specify the version of the images to run. The default is set in the
@@ -22,54 +22,47 @@ services:
2222
environment: ['http.host=0.0.0.0', 'transport.host=127.0.0.1']
2323
ports: ['127.0.0.1:9200:9200']
2424
networks: ['stack']
25-
# Check that Elasticsearch is responding before hitting it with real requests.
26-
healthcheck:
27-
test: ['CMD', 'curl', '-f', '-u', 'elastic:changeme', 'http://localhost:9200']
2825

2926
kibana:
3027
image: docker.elastic.co/kibana/kibana:${TAG}
3128
ports: ['127.0.0.1:5601:5601']
3229
networks: ['stack']
33-
depends_on: {elasticsearch: {condition: service_healthy}}
34-
# Check that Kibana is responding before loading dashboards etc.
35-
healthcheck:
36-
test: ['CMD', 'curl', '-f', 'http://localhost:5601/login']
30+
depends_on: ['elasticsearch']
3731

3832
logstash:
3933
image: docker.elastic.co/logstash/logstash:${TAG}
4034
# Provide a simple pipeline configuration for Logstash with a bind-mounted file.
4135
volumes:
4236
- ./config/logstash.conf:/usr/share/logstash/pipeline/logstash.conf
4337
networks: ['stack']
44-
depends_on: {elasticsearch: {condition: service_healthy}}
38+
depends_on: ['elasticsearch']
4539

4640
filebeat:
4741
image: docker.elastic.co/beats/filebeat:${TAG}
48-
group_add: ['root', 'adm']
4942
# If the host system has logs at "/var/log", mount them at "/mnt/log"
5043
# inside the container, where Filebeat can find them.
5144
# volumes: ['/var/log:/mnt/log:ro']
5245
networks: ['stack']
53-
depends_on: {elasticsearch: {condition: service_healthy}}
46+
depends_on: ['elasticsearch']
5447

5548
heartbeat:
5649
image: docker.elastic.co/beats/heartbeat:${TAG}
5750
networks: ['stack']
58-
depends_on: {elasticsearch: {condition: service_healthy}}
51+
depends_on: ['elasticsearch']
5952

6053
metricbeat:
6154
image: docker.elastic.co/beats/metricbeat:${TAG}
62-
networks: ['stack']
6355
# The commented sections below enable Metricbeat to monitor the Docker host,
6456
# rather than the Metricbeat container. It's problematic with Docker for
6557
# Windows, however, since "/proc", "/sys" etc. don't exist on Windows.
6658
# The same likely applies to OSX (needs testing).
6759
# volumes:
68-
#- /proc:/hostfs/proc:ro
69-
# - /sys/fs/cgroup:/hostfs/sys/fs/cgroup:ro
70-
# - /:/hostfs:ro
60+
# - /proc:/hostfs/proc:ro
61+
# - /sys/fs/cgroup:/hostfs/sys/fs/cgroup:ro
62+
# - /:/hostfs:ro
7163
command: metricbeat -e # -system.hostfs=/hostfs
72-
depends_on: {elasticsearch: {condition: service_healthy}}
64+
networks: ['stack']
65+
depends_on: ['elasticsearch']
7366

7467
packetbeat:
7568
image: docker.elastic.co/beats/packetbeat:${TAG}
@@ -85,39 +78,16 @@ services:
8578
# hostname "elasticsearch". Instead, we'll tell it to find Elasticsearch
8679
# on "localhost", which is the Docker host machine in this context.
8780
command: packetbeat -v -e -E output.elasticsearch.hosts='["localhost:9200"]'
88-
depends_on: {elasticsearch: {condition: service_healthy}}
89-
90-
# Run a short-lived container to import the default dashboards for the Beats.
91-
import_dashboards:
92-
# Any Beats image will do. We'll use Metricbeat.
93-
image: docker.elastic.co/beats/metricbeat:${TAG}
94-
networks: ['stack']
95-
command: >-
96-
/usr/share/metricbeat/scripts/import_dashboards
97-
-beat ""
98-
-file /usr/share/metricbeat/beats-dashboards-${ELASTIC_VERSION}.zip
99-
-es http://elasticsearch:9200
100-
-user elastic
101-
-pass changeme
102-
depends_on: {kibana: {condition: service_healthy}}
103-
104-
# Another short-lived container to create a Kibana index pattern for Logstash.
105-
create_logstash_index_pattern:
106-
# The image just needs curl, and we know that Metricbeat has that.
107-
image: docker.elastic.co/beats/metricbeat:${TAG}
108-
networks: ['stack']
109-
# There's currently no API for creating index patterns, so this is a bit hackish.
110-
command: >-
111-
curl -XPUT http://elastic:changeme@elasticsearch:9200/.kibana/index-pattern/logstash-*
112-
-d '{"title" : "logstash-*", "timeFieldName": "@timestamp"}'
113-
depends_on: {kibana: {condition: service_healthy}}
81+
depends_on: ['elasticsearch']
11482

115-
set_default_index_pattern:
83+
# Run a short-lived container to set up Kibana index patterns and dashboards.
84+
configure_kibana:
85+
# Any Beats image will suffice. We'll use Metricbeat.
11686
image: docker.elastic.co/beats/metricbeat:${TAG}
87+
volumes: ['./scripts/configure-kibana.sh:/usr/local/bin/configure-kibana.sh:ro']
88+
command: /usr/local/bin/configure-kibana.sh
89+
environment: ['ELASTIC_VERSION=${ELASTIC_VERSION}']
11790
networks: ['stack']
118-
command: >-
119-
curl -XPUT http://elastic:changeme@elasticsearch:9200/.kibana/config/${ELASTIC_VERSION}
120-
-d '{"defaultIndex" : "metricbeat-*"}'
121-
depends_on: {kibana: {condition: service_healthy}}
91+
depends_on: ['kibana']
12292

12393
networks: {stack: {}}

scripts/configure-kibana.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
# Wait for Kibana to start up before doing anything.
4+
until curl -s http://kibana:5601/login -o /dev/null; do
5+
echo Waiting for Kibana...
6+
sleep 1
7+
done
8+
9+
# Import the standard Beats dashboards.
10+
/usr/share/metricbeat/scripts/import_dashboards \
11+
-beat '' \
12+
-file /usr/share/metricbeat/beats-dashboards-${ELASTIC_VERSION}.zip \
13+
-es http://elasticsearch:9200 \
14+
-user elastic \
15+
-pass changeme
16+
17+
# Create a Kibana index pattern for Logstash.
18+
# There's currently no API for creating index patterns, so this is a bit hackish.
19+
curl -s -XPUT http://elastic:changeme@elasticsearch:9200/.kibana/index-pattern/logstash-* \
20+
-d '{"title" : "logstash-*", "timeFieldName": "@timestamp"}'
21+
22+
# Set the default index pattern.
23+
curl -s -XPUT http://elastic:changeme@elasticsearch:9200/.kibana/config/${ELASTIC_VERSION} \
24+
-d '{"defaultIndex" : "metricbeat-*"}'

0 commit comments

Comments
 (0)