Site icon installvirtual

Install pghero on mac with docker – performance dashboard for Postgres

Install pghero on Mac

A performance dashboard for Postgres – health checks, suggested indexes, and more. PgHero 2.0 provides, even more, insight into your database performance with two additional features: query details and space stats.

PgHero makes it easy to see the most time-consuming queries during a given time period, but it’s hard to follow an individual query’s performance over time. When you run into issues, it’s not always easy to uncover what happened. Are the top queries during an incident consistently the most time-consuming, or are they new? Did the number of calls increase or was it the average time?

Sourcepghero

Prerequisites

Starting Postgres Container

In this tutorial, I am installing pghero on docker. I am installing pghero for postgres docker container that is running on my Mac. You can install pghero for postgres server running on Mac without docker and you can use pghero docker for remote postgres servers also.

I am starting a new postgres container because I don’t have container running with postgres so I am starting a new container. In next step, I will show you how to install pghero for already running postgres container also.

Create a network for pghero

Firstly we will create a network so that postgres container and pghero container will be on the same network and reachable.

docker network create pghero

Start postgres Container

Now we will start postgres container in the pghero network.

docker run -itd -p 5433:5432 --network pghero --name postgres postgres:9.6.2

docker ps

Now we have postgres container running.

Start pghero container

Now we will start our pghero container with the following options.

docker run -ti --network pghero \
-e DATABASE_URL=postgres://postgres:postgres@postgres:5432/postgres \
-p 8080:8080 --name hero ankane/pghero

Now we have started pghero also let’s go to the browser to view the pghero dashboard.

View the pghero

Now go to any browser and go to localhost:8080 and you will see the dashboard.

Here you go. You can see the queries, connections, and lot of stuff here.

Pghero with already running postgres container

Now I will start postgres with an already running container. You need to start the pghero on the same network in order to connect to postgres container.

[root@installvirtual ~]# docker ps
CONTAINER ID  IMAGE          COMMAND                CREATED        STATUS        PORTS                  NAMES
c8ed89b65990  postgres:9.6.2 "docker-entrypoint.sh" 32 minutes ago Up 32 minutes 0.0.0.0:5433->5432/tcp postgres

Now you need to look up the network of the already running container. Just execute following command and replace the container id with yours.

[root@installvirtual ~]# docker network ls
NETWORK ID         NAME            DRIVER             SCOPE
287eba0f724c       bridge          bridge             local
c4d2699a51a3       host            host               local
8ca745341a40       installvirtual  bridge             local
d4ffb7d56071       none            null               local

Then inspect the docker container and grep Network ID.

[root@installvirtual ~]# docker inspect postgres | grep NetworkID
"NetworkID": "8ca745341a409298912c132dc13974f94f63c31059eaa9279d61357df7d4cbf4"

So now you need to look for first 12 digits of Network ID and match it with our networks. My first 12 digits are  8ca745341a40 and the network of Postgres container is installvirtual.

docker run -ti --network installvirtual \
-e DATABASE_URL=postgres://postgres:postgres@postgres:5432/postgres \
-p 8080:8080 \
--name hero ankane/pghero

Now my pghero is started and it is working and reachable to the Postgres container.

If you get any issues in installing pghero and resolving Postgres container please feel free to comment below.

Exit mobile version