50 lines
1.7 KiB
Bash
Executable File
50 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
if [[ "${DATABASE_URL}" == "" ]]; then
|
|
echo 'Missing DATABASE_URL'
|
|
echo 'example -e DATABASE_URL="user=<db user> password=<db user password> host=<db host> port=<db port> database=<db name>"'
|
|
exit 1
|
|
fi
|
|
|
|
trap shutdown INT
|
|
|
|
function shutdown() {
|
|
pkill -SIGINT postgresql-prometheus-adapter
|
|
}
|
|
|
|
adapter_send_timeout=$(echo "${adapter_send_timeout:-'30s'}" | tr -d "'")
|
|
web_listen_address=$(echo "${web_listen_address:-':9201'}" | tr -d "'")
|
|
web_telemetry_path=$(echo "${web_telemetry_path:-'/metrics'}" | tr -d "'")
|
|
log_level=$(echo "${log_level:-'info'}" | tr -d "'")
|
|
log_format=$(echo "${log_format:-'logfmt'}" | tr -d "'")
|
|
pg_partition=$(echo "${pg_partition:-'hourly'}" | tr -d "'")
|
|
pg_commit_secs=${pg_commit_secs:-30}
|
|
pg_commit_rows=${pg_commit_rows:-20000}
|
|
pg_threads="${pg_threads:-1}"
|
|
parser_threads="${parser_threads:-5}"
|
|
|
|
echo "/usr/local/bin/postgresql-prometheus-adapter \
|
|
--adapter-send-timeout=${adapter_send_timeout} \
|
|
--web-listen-address=${web_listen_address} \
|
|
--web-telemetry-path=${web_telemetry_path} \
|
|
--log.level=${log_level} \
|
|
--log.format=${log_format} \
|
|
--pg-partition=${pg_partition} \
|
|
--pg-commit-secs=${pg_commit_secs} \
|
|
--pg-commit-rows=${pg_commit_rows} \
|
|
--pg-threads=${pg_threads} \
|
|
--parser-threads=${parser_threads}"
|
|
|
|
/usr/local/bin/postgresql-prometheus-adapter \
|
|
--adapter-send-timeout=${adapter_send_timeout} \
|
|
--web-listen-address=${web_listen_address} \
|
|
--web-telemetry-path=${web_telemetry_path} \
|
|
--log.level=${log_level} \
|
|
--log.format=${log_format} \
|
|
--pg-partition=${pg_partition} \
|
|
--pg-commit-secs=${pg_commit_secs} \
|
|
--pg-commit-rows=${pg_commit_rows} \
|
|
--pg-threads=${pg_threads} \
|
|
--parser-threads=${parser_threads} |