Skip to content

Commit 9cdbf7b

Browse files
authored
[+] improve docker compose files (#642)
* [+] add `postgresql-17-pg-qualstats` and `python3-psutil` to Postgres image * [+] use `pgwatch metric print-init` to add test monitoring source * [*] make Grafana use standard storage instead of Postgres
1 parent df9dac8 commit 9cdbf7b

File tree

4 files changed

+11
-22
lines changed

4 files changed

+11
-22
lines changed

docker/Dockerfile.postgres-plpython3u

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ FROM postgres:17
22

33
# Install the necessary packages for plpython3u
44
RUN apt-get update && apt-get install -y \
5-
postgresql-plpython3-17 pg-activity
5+
postgresql-plpython3-17 postgresql-17-pg-qualstats python3-psutil \
6+
pg-activity
67

78
# Clean up
89
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

docker/bootstrap/create_role_db.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@ CREATE ROLE pgwatch WITH
44

55
CREATE DATABASE pgwatch OWNER pgwatch;
66

7-
CREATE DATABASE pgwatch_grafana OWNER pgwatch;
8-
97
CREATE DATABASE pgwatch_metrics OWNER pgwatch;

docker/compose.add-test-db.sh

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@
22

33
cd "$(dirname "${BASH_SOURCE[0]}")"
44

5-
docker compose exec postgres psql -d pgwatch -v ON_ERROR_STOP=1 -c \
6-
"CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
7-
CREATE EXTENSION IF NOT EXISTS plpython3u;
8-
CREATE FUNCTION get_load_average(OUT load_1min float, OUT load_5min float, OUT load_15min float) AS '
9-
from os import getloadavg
10-
la = getloadavg()
11-
return [la[0], la[1], la[2]]'
12-
LANGUAGE plpython3u VOLATILE;
13-
GRANT EXECUTE ON FUNCTION get_load_average() TO pgwatch;
14-
GRANT EXECUTE ON FUNCTION pg_stat_file(text) TO pgwatch;
15-
GRANT EXECUTE ON FUNCTION pg_stat_file(text, boolean) TO pgwatch;
16-
INSERT INTO pgwatch.source (name, preset_config, connstr)
17-
SELECT 'demo', 'exhaustive', 'postgresql://pgwatch:pgwatchadmin@postgres/pgwatch'
5+
export MSYS_NO_PATHCONV=1
6+
7+
# We want to pipe the output of the `pgwatch metric print-init` command to the `psql` command
8+
docker compose exec -T pgwatch /pgwatch/pgwatch metric print-init full | \
9+
docker compose exec -T -i postgres psql -d pgwatch -v ON_ERROR_STOP=1
10+
11+
docker compose exec -T postgres psql -d pgwatch -v ON_ERROR_STOP=1 -c \
12+
"INSERT INTO pgwatch.source (name, preset_config, connstr)
13+
SELECT 'demo', 'full', 'postgresql://pgwatch:pgwatchadmin@postgres/pgwatch'
1814
WHERE NOT EXISTS (SELECT * FROM pgwatch.source WHERE name = 'demo')"

docker/compose.grafana.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ services:
44
image: grafana/grafana:10.4.7
55
user: "0:0"
66
environment:
7-
GF_DATABASE_TYPE: postgres
8-
GF_DATABASE_HOST: postgres:5432
9-
GF_DATABASE_NAME: pgwatch_grafana
10-
GF_DATABASE_USER: pgwatch
11-
GF_DATABASE_PASSWORD: pgwatchadmin
12-
GF_DATABASE_SSL_MODE: disable
137
GF_AUTH_ANONYMOUS_ENABLED: true
148
GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH: /var/lib/grafana/dashboards/1-global-db-overview.json
159
GF_INSTALL_PLUGINS: marcusolsson-treemap-panel

0 commit comments

Comments
 (0)