From 08b727228bacdf75d9f06140abc35d79b7b940d3 Mon Sep 17 00:00:00 2001 From: Ondrej Stasek Date: Tue, 23 Apr 2024 11:42:04 +0200 Subject: [PATCH 1/4] Add pgadmin in docker-compose.yml and README.md --- README.md | 27 +++++++++++++++++++-------- docker-compose.yml | 31 ++++++++++++++++++++++--------- 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index a4c23eea8..1ad217aef 100644 --- a/README.md +++ b/README.md @@ -34,12 +34,12 @@ These commands will build and start services listed in the compose file: ## Monitor Database After start, you could open the [monitoring dashboard](http://localhost:3000/) and start -looking at metrics. You may log in as admin (`admin`/`admin`) to apply changes to dashboards or create new ones. +looking at metrics. To add a test database under monitoring, you can use [built-in WebUI](http://localhost:8080/). Or simply execute from command line: ```shell -$ docker compose up add-test-db --force-recreate +docker compose up add-test-db --force-recreate ```
 [+] Running 2/0
@@ -57,8 +57,8 @@ pgwatch3-add-test-db-1 exited with code 0
 ## Produce Workload
 
 To emulate workload for added test database execute:
-```
-$ docker compose up pgbench
+```shell
+docker compose up pgbench
 ```
 
 [+] Running 2/2
@@ -88,7 +88,7 @@ pgwatch3-pgbench-1  | progress: 10.0 s, 509.6 tps, lat 19.541 ms stddev 9.493, 0
 pgwatch3-pgbench-1  | progress: 185.0 s, 325.3 tps, lat 16.825 ms stddev 8.330, 0 failed
 pgwatch3-pgbench-1  |
 pgwatch3-pgbench-1  |
-pgwatch3-pgbench-1  | transaction type: 
+pgwatch3-pgbench-1  | transaction type: builtin: TPC-B (sort of)
 pgwatch3-pgbench-1  | scaling factor: 50
 pgwatch3-pgbench-1  | query mode: simple
 pgwatch3-pgbench-1  | number of clients: 10
@@ -106,12 +106,23 @@ pgwatch3-pgbench-1  | done in 0.45 s (drop tables 0.45 s).
 pgwatch3-pgbench-1 exited with code 0
 
+## Inspect database + +**Warning:** pgadmin uses port 80. If you want it to use another port, change it in `docker-compose.yml` file. + +To look what is inside postgres database, you can spin up pgadmin: +```shell +docker compose up --detach pgadmin +``` +Go to localhost in your favorite browser and login as `admin@local.com`, password `admin`. Then add new server with +name `pgwatch3`, in tab connection enter host name `postgres`, user `pgwatch3`, password `pgwatch3admin`. + ## Development If you apply any changes to the source code and want to restart the agent, it's usually enough to run: ```shell -$ docker compose up pgwatch3 --build --force-recreate --detach +docker compose up pgwatch3 --build --force-recreate --detach ``` The command above will rebuild the `pgwatch3` agent from sources and relaunch the container. @@ -120,12 +131,12 @@ The command above will rebuild the `pgwatch3` agent from sources and relaunch th If you are running containers in detached mode, you still can follow the logs: ```shell -$ docker compose logs --follow +docker compose logs --follow ``` Or you may check the log of a particular service: ```shell -$ docker compose logs pgwatch3 --follow +docker compose logs pgwatch3 --follow ``` # Contributing diff --git a/docker-compose.yml b/docker-compose.yml index 0e5e4df03..554c18170 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -37,6 +37,7 @@ services: GF_AUTH_ANONYMOUS_ENABLED: true GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH: /var/lib/grafana/dashboards/1-global-db-overview.json GF_INSTALL_PLUGINS: marcusolsson-treemap-panel + GF_AUTH_ANONYMOUS_ORG_ROLE: Admin ports: - "3000:3000" restart: unless-stopped @@ -100,12 +101,24 @@ services: profiles: - pgbench - # prometheus: - # image: prom/prometheus - # command: - # - '--config.file=/etc/prometheus/prometheus.yml' - # ports: - # - 9090:9090 - # restart: unless-stopped - # volumes: - # - "./docker/prometheus.yml:/etc/prometheus/prometheus.yml" + prometheus: + image: prom/prometheus + command: + - '--config.file=/etc/prometheus/prometheus.yml' + ports: + - 9090:9090 + restart: unless-stopped + volumes: + - "./docker/prometheus.yml:/etc/prometheus/prometheus.yml" + profiles: + - prometheus + + pgadmin: + image: dpage/pgadmin4 + environment: + PGADMIN_DEFAULT_EMAIL: admin@local.com + PGADMIN_DEFAULT_PASSWORD: admin + ports: + - "80:80" + profiles: + - pgadmin From c9d6cce9334f1ad676a40e3f2fe0dfd8a2c94c1e Mon Sep 17 00:00:00 2001 From: ondar Date: Wed, 24 Apr 2024 08:40:29 +0200 Subject: [PATCH 2/4] Update README.md Co-authored-by: Pavlo Golub --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1ad217aef..df4ffc637 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,8 @@ pgwatch3-pgbench-1 exited with code 0 ## Inspect database -**Warning:** pgadmin uses port 80. If you want it to use another port, change it in `docker-compose.yml` file. +> [!IMPORTANT] +pgAdmin uses port 80. If you want it to use another port, change it in `docker-compose.yml` file. To look what is inside postgres database, you can spin up pgadmin: ```shell From 2e050d89f98c17ae3311d565a2bdf700b98c8043 Mon Sep 17 00:00:00 2001 From: ondar Date: Wed, 24 Apr 2024 08:41:07 +0200 Subject: [PATCH 3/4] Update README.md Co-authored-by: Pavlo Golub --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index df4ffc637..cbfc79309 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ pgwatch3-pgbench-1 exited with code 0 > [!IMPORTANT] pgAdmin uses port 80. If you want it to use another port, change it in `docker-compose.yml` file. -To look what is inside postgres database, you can spin up pgadmin: +To look what is inside `pgwatch3` database, you can spin up pgAdmin4: ```shell docker compose up --detach pgadmin ``` From cbb096351bfc1331660814436fd96f2deafe18ad Mon Sep 17 00:00:00 2001 From: Ondrej Stasek Date: Wed, 24 Apr 2024 09:32:16 +0200 Subject: [PATCH 4/4] Add pgwatch3 DB automatically to pgadmin --- README.md | 4 ++-- docker-compose.yml | 3 +++ docker/pgadmin_pass | 1 + docker/pgadmin_servers.json | 14 ++++++++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 docker/pgadmin_pass create mode 100644 docker/pgadmin_servers.json diff --git a/README.md b/README.md index cbfc79309..4a4e75af9 100644 --- a/README.md +++ b/README.md @@ -115,8 +115,8 @@ To look what is inside `pgwatch3` database, you can spin up pgAdmin4: ```shell docker compose up --detach pgadmin ``` -Go to localhost in your favorite browser and login as `admin@local.com`, password `admin`. Then add new server with -name `pgwatch3`, in tab connection enter host name `postgres`, user `pgwatch3`, password `pgwatch3admin`. +Go to `localhost` in your favorite browser and login as `admin@local.com`, password `admin`. +Server `pgwatch3` should be already added in `Servers` group. ## Development diff --git a/docker-compose.yml b/docker-compose.yml index 554c18170..37a2a91d1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -118,6 +118,9 @@ services: environment: PGADMIN_DEFAULT_EMAIL: admin@local.com PGADMIN_DEFAULT_PASSWORD: admin + volumes: + - "./docker/pgadmin_servers.json:/pgadmin4/servers.json" + - "./docker/pgadmin_pass:/pgadmin4/pass" ports: - "80:80" profiles: diff --git a/docker/pgadmin_pass b/docker/pgadmin_pass new file mode 100644 index 000000000..6c1b96aa6 --- /dev/null +++ b/docker/pgadmin_pass @@ -0,0 +1 @@ +postgres:5432:postgres:pgwatch3:pgwatch3admin \ No newline at end of file diff --git a/docker/pgadmin_servers.json b/docker/pgadmin_servers.json new file mode 100644 index 000000000..8fc08ea74 --- /dev/null +++ b/docker/pgadmin_servers.json @@ -0,0 +1,14 @@ +{ + "Servers": { + "1": { + "Name": "pgwatch3", + "Group": "Servers", + "Port": 5432, + "Username": "pgwatch3", + "Host": "postgres", + "PassFile": "/pgadmin4/pass", + "SSLMode": "disable", + "MaintenanceDB": "postgres" + } + } +}