Skip to content

Commit 2658c2b

Browse files
authored
Merge pull request #173 from maevsi/fix/grafana/postgres-connection
fix(grafana): source postgres datasource secrets from file
2 parents 89da536 + a71950b commit 2658c2b

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/production/configurations/grafana/dashboards/postgres.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@
213213
"editorMode": "code",
214214
"format": "table",
215215
"rawQuery": true,
216-
"rawSql": "SELECT created as time, row_number() OVER (ORDER BY created) FROM maevsi_private.account",
216+
"rawSql": "SELECT created_at as time, row_number() OVER (ORDER BY created_at) FROM maevsi_private.account",
217217
"refId": "A",
218218
"sql": {
219219
"columns": [

src/production/configurations/grafana/provisioning/datasources/postgres.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ datasources:
88
sslmode: 'disable'
99
name: PostgreSQL
1010
secureJsonData:
11-
password: postgres
11+
password: $__file{/run/secrets/postgres_role_grafana_password}
1212
type: grafana-postgresql-datasource
1313
url: postgres:5432
14-
user: postgres
14+
user: $__file{/run/secrets/postgres_role_grafana_username}

src/production/configurations/postgres/docker-entrypoint-initdb.d/additional-databases.sh

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

33
set -eu
44

5-
username="$(cat /run/secrets/postgres_user)"
5+
postgres_user="$(cat /run/secrets/postgres_user)"
66

77
create_database_and_role() {
88
db_name="$1"
@@ -24,7 +24,7 @@ create_database_and_role() {
2424

2525
echo "[INFO] Creating user and database: '$db_name'"
2626

27-
psql -v ON_ERROR_STOP=1 --username "$username" --dbname "postgres" <<-EOSQL
27+
psql -v ON_ERROR_STOP=1 --username "$postgres_user" --dbname "postgres" <<-EOSQL
2828
CREATE ROLE "$db_username" WITH LOGIN PASSWORD '$db_password';
2929
CREATE DATABASE "$db_name" OWNER "$db_username";
3030
EOSQL

0 commit comments

Comments
 (0)