-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·83 lines (74 loc) · 2.45 KB
/
run.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
echo "Starting Prometheus $PROM_VERSION"
echo "Relevant Environment Variables (PROM_*):"
env | grep PROM_
echo ""
# Flags updated here: https://github.com/prometheus/prometheus/blob/master/cmd/prometheus/main.go
# Logger flags updated here: https://github.com/prometheus/common/blob/master/promlog/flag/flag.go
# With some defaults seen overridden for Docker here: https://github.com/prometheus/prometheus/blob/master/Dockerfile
# Booleans are treated specially in kingpin so they need passing in differently.
declare -a booleans=(
web.enable-lifecycle
web.enable-admin-api
storage.tsdb.no-lockfile
storage.tsdb.allow-overlapping-blocks
storage.tsdb.wal-compression
)
declare -a flags=(
config.file
web.listen-address
web.read-timeout
web.max-connections
web.external-url
web.route-prefix
web.user-assets
web.console.templates
web.console.libraries
web.page-title
web.cors.origin
storage.tsdb.path
storage.tsdb.min-block-duration
storage.tsdb.max-block-duration
storage.tsdb.wal-segment-size
storage.tsdb.retention.time
storage.tsdb.retention.size
storage.remote.flush-deadline
storage.remote.read-sample-limit
storage.remote.read-concurrent-limit
storage.remote.read-max-bytes-in-frame
rules.alert.for-outage-tolerance
rules.alert.for-grace-period
rules.alert.resend-delay
alertmanager.notification-queue-capacity
alertmanager.timeout
query.lookback-delta
query.timeout
query.max-concurrency
query.max-samples
log.format
log.level
)
# Defaults taken from original prometheus Dockerfile
declare -a command=(
"/app/prometheus"
"--config.file=/etc/prometheus/prometheus.yml"
"--storage.tsdb.path=/prometheus"
"--web.console.libraries=/usr/share/prometheus/console_libraries"
"--web.console.templates=/usr/share/prometheus/consoles"
)
for flag in "${booleans[@]}"; do
envVarName="PROM_$(echo "${flag}" | tr 'a-z-.' 'A-Z__')"
lowerVarValue="$(echo "${!envVarName}" | tr 'A-Z' 'a-z')"
if [ ! -z "${lowerVarValue}" ]; then
if [ "${lowerVarValue}" == "true" ]; then command+=("--${flag}"); else command+=("--no-${flag}"); fi
fi
done
for flag in "${flags[@]}"; do
envVarName="PROM_$(echo "${flag}" | tr 'a-z-.' 'A-Z__')"
if [ ! -z "${!envVarName}" ]; then
command+=("--${flag}=${!envVarName}")
fi
done
unset envVarName lowerVarValue flag booleans flags
set -ex
exec "${command[@]}" $@