This repository has been archived by the owner on Jul 27, 2023. It is now read-only.
forked from CiscoCloud/mantl-kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaunch.sh
executable file
·63 lines (52 loc) · 2.1 KB
/
launch.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
set -ex
# Required vars
export ELASTICSEARCH_SERVICE=${ELASTICSEARCH_SERVICE:-client_port.elasticsearch-executor}
export KIBANA_SERVICE=${KIBANA_SERVICE:-kibana}
export KIBANA_IMAGE_TAG=${KIBANA_IMAGE_TAG:-4.3.2}
export KIBANA_BUILD_NUM=${KIBANA_BUILD_NUM:-9520}
CONSUL_TEMPLATE=${CONSUL_TEMPLATE:-/usr/local/bin/consul-template}
CONSUL_CONNECT=${CONSUL_CONNECT:-consul.service.consul:8500}
CONSUL_MINWAIT=${CONSUL_MINWAIT:-2s}
CONSUL_MAXWAIT=${CONSUL_MAXWAIT:-10s}
CONSUL_LOGLEVEL=${CONSUL_LOGLEVEL:-warn}
CONSUL_SSL_VERIFY=${CONSUL_SSL_VERIFY:-true}
KIBANA_LOGSTASH_CONFIG=${KIBANA_LOGSTASH_CONFIG:-false}
[[ -n "${CONSUL_CONNECT}" ]] && ctargs="${ctargs} -consul ${CONSUL_CONNECT}"
[[ -n "${CONSUL_SSL}" ]] && ctargs="${ctargs} -ssl"
[[ -n "${CONSUL_SSL}" ]] && ctargs="${ctargs} -ssl-verify=${CONSUL_SSL_VERIFY}"
[[ -n "${CONSUL_TOKEN}" ]] && ctargs="${ctargs} -token ${CONSUL_TOKEN}"
wait_for_config() {
${CONSUL_TEMPLATE} -config /consul-template/config.d/kibana.cfg \
-log-level ${CONSUL_LOGLEVEL} \
-wait ${CONSUL_MINWAIT}:${CONSUL_MAXWAIT} \
-once \
${ctargs}
# make sure we found an elasticsearch service to connect to
grep elasticsearch.url \
/opt/kibana/config/kibana.yml 1>/dev/null
}
vars=$@
# wait until we discover a valid elasticsearch service to connect to
ATTEMPT=0
until wait_for_config || [ $ATTEMPT -eq 6 ]; do
echo "waiting for Kibana configuration..."
cat /opt/kibana/config/kibana.yml
echo "attempt: $(( ATTEMPT++ ))"
sleep 10
done
if [[ $ATTEMPT -eq 6 ]]; then
echo "$ELASTICSEARCH_SERVICE not found."
exit 1
fi
# show config
cat /opt/kibana/config/kibana.yml
if [[ $KIBANA_LOGSTASH_CONFIG == "true" ]]; then
# run consul-template in the background to create index pattern + dashboard
${CONSUL_TEMPLATE} -config /consul-template/config.d/kibana-dashboard.cfg \
-log-level ${CONSUL_LOGLEVEL} \
-wait ${CONSUL_MINWAIT}:${CONSUL_MAXWAIT} \
${ctargs} &
fi
# run kibana
exec kibana ${vars}