postgresql + prometheus + grafana 监控

非 Y 不嫁゛ 提交于 2020-11-04 19:52:07

postgres 

安装  postgres_exporter

下载:去 github 下载最新的 exporter 解压出一个二进制的文件。

将文件夹放到 /opt 目录下,创建  postgres_exporter.env 文件

# postgres_exporter.env

DATA_SOURCE_NAME="postgresql://postgres:postgres@localhost:5432/?sslmode=disable"

创建 systemd service 单元

sudo vim /etc/systemd/system/postgres_exporter.service

[Unit]
Description=Prometheus exporter for Postgresql
Wants=network-online.target
After=network-online.target

[Service]
User=postgres
Group=postgres
WorkingDirectory=/opt/postgres_exporter
EnvironmentFile=/opt/postgres_exporter/postgres_exporter.env
ExecStart=/opt/postgres_exporter/postgres_exporter
Restart=always

[Install]
WantedBy=multi-user.target

启动服务

systemctl start postgres_exporter.service

添加 抓取配置

scrape_configs:
  - job_name: 'postgres_exporter'
    static_configs:
      - targets: ['localhost:9187']

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!