Skip to content

Commit 150646d

Browse files
authored
feat: make analytics and logging stack optional (#99)
1 parent 8e160e3 commit 150646d

6 files changed

Lines changed: 199 additions & 97 deletions

File tree

.env

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,23 @@ PLACE_METRICS_ROUTE=monitor
3838

3939
ELASTIC_HOST=elastic
4040
ELASTIC_PORT=9200
41-
ELASTIC_VERSION=7.16.2
41+
ELASTIC_VERSION=7.10.2
4242

4343
ETCD_HOST=etcd
4444
ETCD_PORT=2379
4545
ETCD_VERSION=3.5.1
4646

47+
REDIS_URL=redis://redis:6379
48+
49+
RETHINKDB_DB=place_development
50+
RETHINKDB_HOST=rethink
51+
RETHINKDB_PORT=28015
52+
RETHINKDB_VERSION=2.4
53+
54+
# Analytics variables
55+
56+
ENABLE_ANALYTICS=false
57+
4758
# INFLUX_USER=placeos
4859
# INFLUX_PASSWORD=development
4960

@@ -52,20 +63,14 @@ INFLUX_HOST=http://influxdb:8086
5263
INFLUX_ORG=PlaceOS
5364
INFLUX_RETENTION=4w
5465

55-
REDIS_URL=redis://redis:6379
56-
57-
RETHINKDB_DB=place_development
58-
RETHINKDB_HOST=rethink
59-
RETHINKDB_PORT=28015
60-
RETHINKDB_VERSION=2.4
61-
6266
# Staff API variables
6367

6468
POSTGRES_USER=placeos
6569
POSTGRES_PASSWORD=development
6670

67-
# Monitor Node variables
71+
# Logging variables
6872

73+
ENABLE_KIBANA=false
6974
LOGSTASH_HOST=logstash
7075
LOGSTASH_PORT=12201
7176
KIBANA_PORT=443

compose-files/metricbeat.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

docker-compose.yml

Lines changed: 121 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ x-jwt-public-key-env: &jwt-public-key-env .env.public_key
3434
x-secret-key-env: &secret-key-env .env.secret_key
3535

3636
x-elastic-client-env: &elastic-client-env
37+
ELASTIC_HOST: ${ELASTIC_HOST:-elastic}
38+
ELASTIC_PORT: ${ELASTIC_PORT:-9200}
3739
ES_HOST: ${ELASTIC_HOST:-elastic}
3840
ES_PORT: ${ELASTIC_PORT:-9200}
3941

@@ -191,9 +193,12 @@ services:
191193
PLACE_LOADER_WWW: www
192194

193195
source:
194-
image: docker.io/placeos/source:${PLACE_SOURCE_TAG:-nightly}
196+
image: placeos/source:${PLACE_SOURCE_TAG:-nightly}
197+
profiles:
198+
- analytics
195199
restart: always
196200
container_name: source
201+
hostname: source
197202
<<: *std-network
198203
<<: *std-logging
199204
depends_on:
@@ -235,6 +240,7 @@ services:
235240
postgres: # Database used by Staff API
236241
image: postgres:${POSTGRES_VERSION:-13-alpine}
237242
container_name: postgres
243+
hostname: postgres
238244
restart: unless-stopped
239245
<<: *std-network
240246
<<: *std-logging
@@ -248,6 +254,7 @@ services:
248254
staff: # Staff API
249255
image: placeos/staff-api:${PLACE_STAFF_API_TAG:-nightly}
250256
container_name: staff
257+
hostname: staff
251258
restart: unless-stopped
252259
<<: *std-network
253260
<<: *std-logging
@@ -323,12 +330,13 @@ services:
323330
# Resources
324331

325332
elastic:
326-
image: blacktop/elasticsearch:${ELASTIC_VERSION:-7.9.1}
333+
image: blacktop/elasticsearch:${ELASTIC_VERSION:-7.10.2}
327334
restart: always
328335
container_name: elastic
329336
hostname: elastic
330337
healthcheck:
331338
test: wget -q --no-verbose --tries=1 --spider http://localhost:9200/_cat/health
339+
start_period: 1m
332340
<<: *std-network
333341
<<: *std-logging
334342
volumes:
@@ -356,23 +364,28 @@ services:
356364

357365
influxdb:
358366
image: influxdb:${INFLUXDB_IMAGE_TAG:-2.0.8-alpine}
359-
container_name: influx
367+
profiles:
368+
- analytics
360369
restart: always
370+
container_name: influx
371+
hostname: influx
361372
<<: *std-network
362373
<<: *std-logging
363-
hostname: influx
364374
healthcheck:
365375
test: influx bucket list
366376
volumes:
367377
- type: volume
368378
source: influx-data
369379
target: /root/.influxdbv2
370380
command: "--reporting-disabled"
371-
381+
372382
chronograf:
373383
image: chronograf:${CHRONOGRAF_IMAGE_TAG:-1.9}
374-
container_name: chronograf
384+
profiles:
385+
- analytics
375386
restart: always
387+
container_name: chronograf
388+
hostname: chronograf
376389
<<: *std-network
377390
<<: *std-logging
378391
env_file:
@@ -394,6 +407,8 @@ services:
394407

395408
mosquitto:
396409
image: iegomez/mosquitto-go-auth:${MOSQUITTO_IMAGE_TAG:-latest}
410+
profiles:
411+
- analytics
397412
restart: always
398413
container_name: mosquitto
399414
hostname: mosquitto
@@ -466,3 +481,103 @@ services:
466481
target: /data/rethinkdb_data
467482
environment:
468483
TZ: $TZ
484+
485+
# Aggregates logs and forwards them to Elasticsearch.
486+
logstash:
487+
image: blacktop/logstash:${ELASTIC_VERSION:-7.10.2}
488+
profiles:
489+
- kibana
490+
restart: always
491+
container_name: logstash
492+
hostname: logstash
493+
<< : *std-network
494+
<< : *std-logging
495+
depends_on:
496+
- validate-logstash-config
497+
volumes:
498+
- ${PWD}/config/logstash/config:/config
499+
- ${PWD}/config/logstash/patterns:/opt/logstash/extra_patterns
500+
command: logstash -f /config
501+
502+
# Run 'docker-compose run --rm validate-logstash-config' to quickly check the logstash config.
503+
validate-logstash-config:
504+
image: blacktop/logstash:${ELASTIC_VERSION:-7.10.2}
505+
profiles:
506+
- kibana
507+
restart: "no"
508+
container_name: validate-logstash
509+
<< : *std-network
510+
<< : *std-logging
511+
volumes:
512+
- ${PWD}/config/logstash/config:/config
513+
command: logstash -t -f /config
514+
515+
# Sends all container json-file logs to logstash
516+
logspout:
517+
image: vincit/logspout-gelf:3.2.6-alpine
518+
profiles:
519+
- kibana
520+
restart: unless-stopped
521+
container_name: logspout
522+
hostname: logspout
523+
<< : *std-network
524+
<< : *std-logging
525+
volumes:
526+
- /var/run/docker.sock:/var/run/docker.sock
527+
command: gelf://${LOGSTASH_HOST}:${LOGSTASH_PORT}
528+
529+
kibana:
530+
image: blacktop/kibana:${ELASTIC_VERSION:-7.10.2}
531+
profiles:
532+
- kibana
533+
restart: always
534+
container_name: kibana
535+
hostname: kibana
536+
<< : *std-network
537+
<< : *std-logging
538+
environment:
539+
<<: *elastic-client-env
540+
NODE_OPTIONS: "--max-old-space-size=200" # fixes memory leak (https://github.com/elastic/kibana/issues/5170)
541+
HTTPS_METHOD: "nohttp"
542+
ELASTICSEARCH_HOSTS: "http://${ELASTIC_HOST}:${ELASTIC_PORT}"
543+
SERVER_BASEPATH: "/${PLACE_METRICS_ROUTE}"
544+
SERVER_REWRITEBASEPATH: "true"
545+
SERVER_PUBLICBASEURL: "https://${PLACE_DOMAIN}/${PLACE_METRICS_ROUTE}"
546+
547+
# Takes care of piling up Elasticsearch indices/logs. Can do many other things as well.
548+
# Set up a cron job that runs "docker-compose run --rm curator --config /config.yml /action-file.yml" every once in a while.
549+
curator:
550+
image: bobrik/curator:5.8.1
551+
profiles:
552+
- kibana
553+
container_name: curator
554+
hostname: curator
555+
<< : *std-network
556+
<< : *std-logging
557+
volumes:
558+
- ${PWD}/config/curator/action-file.yml:/action-file.yml
559+
- ${PWD}/config/curator/config.yml:/config.yml
560+
561+
# Gets metrics from host machine and send to elastic
562+
metricbeat:
563+
image: elastic/metricbeat:${ELASTIC_VERSION:-7.10.2}
564+
profiles:
565+
- metricbeat
566+
restart: unless-stopped
567+
container_name: metricbeat
568+
hostname: metricbeat
569+
user: root
570+
<< : *std-network
571+
<< : *std-logging
572+
environment:
573+
<<: *elastic-client-env
574+
volumes:
575+
- /proc:/hostfs/proc:ro
576+
- /sys/fs/cgroup:/hostfs/sys/fs/cgroup:ro
577+
- /:/hostfs:ro
578+
- /var/run/docker.sock:/var/run/docker.sock:ro
579+
- ${PWD}/config/metricbeat.yml:/usr/share/metricbeat/metricbeat.yml
580+
cap_add:
581+
- SYS_PTRACE
582+
- DAC_READ_SEARCH
583+
command: ["metricbeat", "-e", "--strict.perms=false", "-system.hostfs=/hostfs", "-E", "output.elasticsearch.hosts=[$ELASTIC_HOST:$ELASTIC_PORT]"]

0 commit comments

Comments
 (0)