Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Add setup script for 'apm-server' #82

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions docker-compose.setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ services:
image: docker.elastic.co/apm/apm-server:${TAG}
container_name: setup_apm_server
user: root
command: ['/bin/bash', '-c', 'cat /usr/local/bin/setup-beat.sh | tr -d "\r" | bash -s apm-server']
command: ['/bin/bash', '-c', 'cat /usr/local/bin/setup-apm-server.sh | tr -d "\r" | bash']
volumes:
- './config:/config'
- './scripts/setup-beat.sh:/usr/local/bin/setup-beat.sh:ro'
- './scripts/setup-apm-server.sh:/usr/local/bin/setup-apm-server.sh:ro'
- './config/apm-server/apm-server.yml:/usr/share/apm-server/apm-server.yml'
- './config/ssl/ca/ca.crt:/usr/share/apm-server/certs/ca/ca.crt'
environment: ['ELASTIC_PASSWORD=${ELASTIC_PASSWORD}']
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ services:
- source: ca.crt
target: /usr/share/apm-server/certs/ca/ca.crt
volumes:
- './scripts/setup-beat.sh:/usr/local/bin/setup-beat.sh:ro'
- './scripts/setup-apm-server.sh:/usr/local/bin/setup-apm-server.sh:ro'
depends_on: ['elasticsearch', 'kibana']
healthcheck:
test: curl --cacert /usr/share/elasticsearch/config/certs/ca/ca.crt -s https://localhost:8200/healthcheck >/dev/null; if [[ $$? == 52 ]]; then echo 0; else echo 1; fi
Expand Down
27 changes: 27 additions & 0 deletions scripts/setup-apm-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

set -euo pipefail

until curl -s "http://kibana:5601/login" | grep "Loading Kibana" > /dev/null; do
echo "Waiting for kibana..."
sleep 5
done

# apm-server.yml needs to be owned by root
chown root /usr/share/apm-server/apm-server.yml

echo "Creating keystore..."
echo "y" | /usr/share/apm-server/apm-server keystore create --force

echo "Adding ELASTIC_PASSWORD to keystore..."
echo "$ELASTIC_PASSWORD" | /usr/share/apm-server/apm-server keystore add 'ELASTIC_PASSWORD' --stdin
/usr/share/apm-server/apm-server keystore list

echo "Setting up dashboards..."
# Load the sample dashboards for APM.
# REF: https://www.elastic.co/guide/en/apm/server/current/load-kibana-dashboards.html
/usr/share/apm-server/apm-server setup --dashboards

echo "Copy keystore to ./config dir"
mv /usr/share/apm-server/apm-server.keystore /config/apm-server/apm-server.keystore
chown 1000:1000 /config/apm-server/apm-server.keystore
2 changes: 1 addition & 1 deletion scripts/setup-beat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ beat=$1

until curl -s "http://kibana:5601/login" | grep "Loading Kibana" > /dev/null; do
echo "Waiting for kibana..."
sleep 1
sleep 5
done

chmod go-w /usr/share/$beat/$beat.yml
Expand Down