Prometheus Monitoring of PG
Go to github and download the compiled exporter file
Address: https://github.com/wrouesnel/postgres_exporter/releases
Tar xf postgres_exporter_v0.4.1_linux-amd64.tar.gz-C / opt/
Cd / opt/postgres_exporter_v0.4.1_linux-amd64
The vim start.sh startup script contains the following
Replace the password under #! / bin/bashcd / opt/postgres_exporter_v0.4.1_linux-amd64export PATH=/usr/local/pgsql/bin:$PATH# with your own postgres user password export DATA_SOURCE_NAME= "user=postgres host=localhost password=123456 port=5432 dbname=postgres sslmode=disable" nohup. / postgres_exporter-- web.listen-address= ": 9187" > / dev/null 2 > & 1 &
Then, add the corresponding target to the Prometheus
Once the data is collected, you can draw a picture in grafana, like this:
Usually, we will also deploy a node_exporter to collect monitoring information at the host level at the same time. Something like this:
Because blog is not convenient to upload files, I will not post grafana template files here.