PG Overview

This dashboard works with postgres_exporter for prometheus

PG Overview screenshot 1
PG Overview screenshot 2

PostgreSQL_exporter

1.下载和配置

​ 下载文件:postgres_exporter-0.10.0.linux-amd64.tar.gz ​ 解压:

shell
tar -C /opt -xvf postgres_exporter-0.10.0.linux-amd64.tar.gz
cd /opt && mv postgres_exporter-0.10.0.linux-amd64 postgres_exporter
cd postgres_exporter

添加脚本: start.sh

shell
sudo -u postgres DATA_SOURCE_NAME="user=postgres host=/var/run/postgresql/ sslmode=disable" postgres_exporter #需要通过用户postgres启动

添加至systemd:

shell
vim /usr/lib/systemd/system/postgres_exporter.service
[Unit]
Description=postgres_exporter
After=network.target
[Service]
Type=simple
ExecStart=/PATH/TO/start.sh 
Restart=on-failure
[Install]
WantedBy=multi-user.target

​ 启动:

shell
systemctl daemon-reload
systemctl start postgres_exporter
systemctl status postgres_exporter
systemctl enable postgres_exporte

2.接入prometheus

edit prometheus.yml

yaml
  - job_name: "postgresql"
    file_sd_configs:
      - files:
          - targets/postgresql.yml
        refresh_interval: 10m

targets/postgresql.yml

yaml
      - targets: ["10.1xx.1.1xx:9187"]
        labels:
          instance: 10.1xx.1.1xx_postgresql
          targets: "10.1xx.1.1xx:9187"
Revisions
RevisionDescriptionCreated

Get this dashboard

Import the dashboard template

or

Download JSON

Datasource
Dependencies