Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit a0293ff

Browse files
authored
[*] optimize Scalefield image and enable async mode for prometheus (#785)
1 parent 17d8d08 commit a0293ff

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

docker-launcher-scalefield.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#!/bin/bash
1+
#!/bin/sh
2+
3+
# Export environment variables with default values
24
export USER=${DATA_SOURCE_USER:-postgres}
35
export PASSWORD=${DATA_SOURCE_PASS:-postgres}
46
export NAME=${DATA_SOURCE_URI:-localhost}
@@ -7,8 +9,9 @@ export CUSTOMER=${PG_EXPORTER_CONSTANT_LABEL_CUSTOMER:-customer}
79
export CLUSTER_NAME=${PG_EXPORTER_CONSTANT_LABEL_CLUSTER_NAME:-cluster_name}
810
export SUPPORT_PLAN=${PG_EXPORTER_CONSTANT_LABEL_SUPPORT_PLAN:-support_plan}
911

10-
cat /pgwatch2/config/scalefield.template | sed "s/%USER%/$USER/;s/%PASSWORD%/$PASSWORD/;s/%NAME%/$NAME/;s/%CUSTOMER%/$CUSTOMER/;s/%CLUSTER_NAME%/$CLUSTER_NAME/;s/%SUPPORT_PLAN%/$SUPPORT_PLAN/" > /pgwatch2/config/scalefield.yaml
12+
# Use envsubst to substitute the variables in the template
13+
envsubst < /pgwatch2/config/scalefield.template > /pgwatch2/config/scalefield.yaml
1114

1215
/pgwatch2/metrics/00_helpers/rollout_helper.py --mode single-db --host "$CLUSTERNAME" --dbname postgres --user "$USER" --password "$PASSWORD" --monitoring-user "$USER" --confirm --metrics-path /pgwatch2/metrics/00_helpers/ --helpers get_load_average,get_psutil_cpu,get_psutil_disk_io_total,get_psutil_disk,get_psutil_mem --excluded-helpers ""
1316

14-
exec /pgwatch2/pgwatch2 -c /pgwatch2/config/scalefield.yaml --adhoc-create-helpers=true --prometheus-port=9189 --datastore=prometheus
17+
exec /pgwatch2/pgwatch2 -c /pgwatch2/config/scalefield.yaml --adhoc-create-helpers=true --prometheus-async-mode=true --prometheus-port=9189 --datastore=prometheus

docker/Dockerfile-scalefield

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ ENV GIT_TIME=${GIT_TIME}
99
ADD pgwatch2 /pgwatch2
1010
RUN cd /pgwatch2 && bash build_gatherer.sh
1111

12-
13-
FROM ubuntu:22.04
14-
15-
RUN apt-get -q update && apt-get -qy install wget git python3 python3-psycopg2 python3-yaml && apt autoremove -y && mkdir /pgwatch2
12+
FROM alpine
13+
14+
RUN apk update && \
15+
apk add --no-cache git python3 py3-psycopg2 py3-yaml && \
16+
apk add --no-cache --virtual .build-deps && \
17+
apk add --no-cache gettext && \
18+
apk add --no-cache libc6-compat && \
19+
mkdir /pgwatch2
1620

1721
ADD pgwatch2/metrics /pgwatch2/metrics
1822
ADD pgwatch2/config /pgwatch2/config

pgwatch2/config/scalefield.template

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
- unique_name: %NAME%
1+
- unique_name: ${NAME}
22
dbtype: postgres
33
host: 127.0.0.1
44
dbname: postgres
5-
user: %USER%
6-
password: %PASSWORD%
5+
user: ${USER}
6+
password: ${PASSWORD}
77
sslmode: require # supported options: disable, require, verify-ca, verify-full
88
stmt_timeout: 5 # in seconds
99
is_superuser: true
@@ -15,9 +15,9 @@
1515
dbname_exclude_pattern:
1616
is_enabled: true
1717
custom_tags:
18-
support_plan: %SUPPORT_PLAN%
19-
customer: %CUSTOMER%
20-
cluster_name: %CLUSTER_NAME%
18+
support_plan: ${SUPPORT_PLAN}
19+
customer: ${CUSTOMER}
20+
cluster_name: ${CLUSTER_NAME}
2121
group: default # just for logical grouping of DB hosts or for "sharding", i.e. splitting the workload between many gatherer daemons
2222
sslrootcert: ''
2323
sslcert: ''

0 commit comments

Comments
 (0)