2
2
3
3
set -euo pipefail
4
4
5
- # Starts a prometheus instance in agent-mode, forwarding to a central
6
- # instance. Intended to enable metrics collection from temporary networks running
7
- # locally and in CI.
5
+ # - Starts a prometheus instance in agent-mode to collect metrics from nodes running
6
+ # locally and in CI.
8
7
#
9
- # The prometheus instance will remain running in the background and will forward
10
- # metrics to the central instance for all tmpnet networks .
8
+ # - promtail will remain running in the background and will forward metrics to the
9
+ # specified prometheus endpoint .
11
10
#
12
- # To stop it:
13
- #
14
- # $ kill -9 `cat ~/.tmpnet/prometheus/run.pid` && rm ~/.tmpnet/prometheus/run.pid
11
+ # - Each node is configured with a file written to ~/.tmpnet/prometheus/file_sd_configs
15
12
#
13
+ # - To stop the running instance:
14
+ # $ kill -9 `cat ~/.tmpnet/promtheus/run.pid` && rm ~/.tmpnet/promtail/run.pid
16
15
17
16
# e.g.,
18
17
# PROMETHEUS_ID=<id> PROMETHEUS_PASSWORD=<password> ./scripts/run_prometheus.sh
45
44
46
45
PROMETHEUS_PASSWORD=" ${PROMETHEUS_PASSWORD:- } "
47
46
if [[ -z " ${PROMETHEUS_PASSWORD} " ]]; then
48
- echo " Plase provide a value for PROMETHEUS_PASSWORD"
47
+ echo " Please provide a value for PROMETHEUS_PASSWORD"
49
48
exit 1
50
49
fi
51
50
@@ -64,13 +63,13 @@ if ! command -v "${CMD}" &> /dev/null; then
64
63
65
64
# Determine the arch
66
65
if which sw_vers & > /dev/null; then
67
- echo " on macos, only amd64 binaries are available so rosetta is required on apple silicon machines."
68
- echo " to avoid using rosetta, install via homebrew: brew install prometheus"
66
+ echo " On macos, only amd64 binaries are available so rosetta is required on apple silicon machines."
67
+ echo " To avoid using rosetta, install via homebrew: brew install prometheus"
69
68
DIST=darwin
70
69
else
71
70
ARCH=" $( uname -i) "
72
71
if [[ " ${ARCH} " != " x86_64" ]]; then
73
- echo " on linux, only amd64 binaries are available. manual installation of prometheus is required."
72
+ echo " On linux, only amd64 binaries are available. manual installation of prometheus is required."
74
73
exit 1
75
74
else
76
75
DIST=" linux"
90
89
FILE_SD_PATH=" ${PROMETHEUS_WORKING_DIR} /file_sd_configs"
91
90
mkdir -p " ${FILE_SD_PATH} "
92
91
93
- echo " writing configuration... "
94
- cat > " ${PROMETHEUS_WORKING_DIR} " /prometheus.yaml << EOL
92
+ CONFIG_PATH= " ${PROMETHEUS_WORKING_DIR} /prometheus.yaml "
93
+ cat > " ${CONFIG_PATH} " << EOL
95
94
# my global config
96
95
global:
97
96
# Make sure this value takes into account the network-shutdown-delay in tests/fixture/e2e/env.go
@@ -112,9 +111,12 @@ remote_write:
112
111
username: "${PROMETHEUS_ID} "
113
112
password: "${PROMETHEUS_PASSWORD} "
114
113
EOL
114
+ echo " Wrote configuration to ${CONFIG_PATH} "
115
115
116
- echo " starting prometheus..."
116
+ echo " Starting prometheus..."
117
117
cd " ${PROMETHEUS_WORKING_DIR} "
118
118
nohup " ${CMD} " --config.file=prometheus.yaml --web.listen-address=localhost:0 --enable-feature=agent > prometheus.log 2>&1 &
119
119
echo $! > " ${PIDFILE} "
120
- echo " running with pid $( cat " ${PIDFILE} " ) "
120
+ echo " prometheus started with pid $( cat " ${PIDFILE} " ) "
121
+ # shellcheck disable=SC2016
122
+ echo ' To stop prometheus: "kill -SIGTERM `cat ~/.tmpnet/prometheus/run.pid` && rm ~/.tmpnet/prometheus/run.pid"'
0 commit comments