here are some commands to setup pmm monitoring server and client
docker compose up -d
wget https://repo.percona.com/apt/percona-release_latest.$(lsb_release -sc)_all.deb
sudo dpkg -i percona-release_latest.$(lsb_release -sc)_all.deb
sudo apt update
sudo apt install pmm2-client
sudo pmm-admin config --server-insecure-tls --server-url=https://admin:<password>@<pmm_server_ip_address>:<https-port>
http://<pmm-server-ip>:<http-port>/graph/inventory/nodes
if you database on the docker container you can use this :
sudo docker exec -it <container-name> psql -d <db-name> -U <db-user>
and run this scripts:
CREATE USER pmm WITH SUPERUSER ENCRYPTED PASSWORD '<pass>';
GRANT ALL PRIVILEGES ON DATABASE <database-name> TO pmm;
ALTER USER pmm CONNECTION LIMIT 10;
CREATE EXTENSION pg_stat_statements SCHEMA public;
GRANT pg_read_all_stats TO pmm;
go to /var/lib/postgresql/data/pg_hba.conf
and add this on pg_hba.conf:
host all pmm <postgres-server-ip> md5
go to /var/lib/postgresql/data/postgresql.conf
and add this on postgresql.conf end of line:
shared_preload_libraries = 'pg_stat_statements'
track_activity_query_size = 2048 # Increase tracked query string size
pg_stat_statements.track = all # Track all statements including nested
track_io_timing = on # Capture read/write stats
sudo pmm-admin add postgresql --username=pmm --password=<pass> --host=127.0.0.1 --port=,db-port> --database=<database-name> --service-name=<service-name> --query-source=pgstatements comments-parsing="off" --debug