To collect WAL metrics, the user must have a `superuser` role.Ĭopy postgresql/ to Zabbix agent home directory /var/lib/zabbix/. GRANT SELECT ON pg_stat_database TO zbx_monitor
Pgadmin 4 connect to docker postgres 9.6 install#
Install Zabbix agent and create a read-only zbx_monitor user with proper access to your PostgreSQL server.įor PostgreSQL version 10 and above: CREATE USER zbx_monitor WITH PASSWORD '' INHERIT įor PostgreSQL version 9.6 and below: CREATE USER zbx_monitor WITH PASSWORD '' See Zabbix template operation for basic instructions. This template was tested on PostgreSQL versions 9.6, 10 and 11 on Linux and Windows. Now, you can manage your PostgreSQL databases from DataGrip.Templates to monitor PostgreSQL by Zabbix. You should see the PostgreSQL database server details if everything works. Now, type in the Docker host IP address 192.168.20.160 (in my case) as the Host, 5432 as the Port, admin as the User, secret as the Password, postgres as the Database and click on Test Connection. In case of DataGrip, click on + from the Databases section and go to Data Source > PostgreSQL.
You can also access your PostgreSQL database server from DataGrip IDE or any other SQL IDEs.
Now, you can work with your PostgreSQL database as much as you want. PgAdmin 4 should be connected to your PostgreSQL database. Now, go to the Connection tab and type in pgsql-server as Host name/address, 5432 as Port, postgres as Maintenance database, admin as Username, secret as Password and check Save password? checkbox. In the General tab, type in your server Name. Now, to add the PostgreSQL server running as a Docker container, right click on Servers, and then go to Create > Server… Once you login, you should see the pgAdmin dashboard. Visit from your Docker host or from any computer on your network. Now, you can easily access pgAdmin 4 from your web browser. So, make sure to replace it with yours from now on. In my case, the IP address of my Docker host 192.168.20.160. Now, to start the db and pgadmin services, run the following command: So, you can access the PostgreSQL server using pgsql-server as the hostname (no IP address required). In the pgadmin service, a hostname alias pgsql-server to the db container is created. In the pgadmin service, the container port 80 (right) is mapped to the Docker host port 8080 (left). In the db service, the container port 5432 (right) is mapped to the Docker host port 5432 (left). In the pgadmin service, all the contents of the /var/lib/pgadmin directory will be saved permanently in the pgadmin-data volume. In db service, all the contents of the /var/lib/postgresql/data directory will be saved permanently in the db-data volume. The PGADMIN_LISTEN_PORT is used to set the pgAdmin port 80 in the container. In pgadmin service, the PGADMIN_DEFAULT_EMAIL, PGADMIN_DEFAULT_PASSWORD environment variables are used to set the login email and password of pgAdmin web interface respectively.
The PGDATA environment variable is used to configure the PostgreSQL server to store the data to /var/lib/postgresql/data directory of the container. In db service, the POSTGRES_DB, POSTGRES_USER, POSTGRES_PASSWORD environment variables are used to set the default database name, admin username and admin user password for the PostgreSQL server respectively. Pgadmin service will run the dpage/pgadmin4:4.18 image (from DockerHub) in another Docker container. Here, I have created 2 services db and pgadmin.ĭb service will run the postgres:12.2 image (from DockerHub) in a Docker container. The docker-compose.yaml file should look as follows.