ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

使用prometheus+grafana监控postgresql的测试

2022-02-19 19:02:17  阅读:399  来源: 互联网

标签:exporter postgresql amd64 grafana prometheus https com


目的

使用两台机器测试prometheus,监控机器指标和postgresql指标

server1 安装prometheus server和grafana

server2 安装 node_exporter和postgres_exporter

安装

wget https://github.com/prometheus/prometheus/releases/download/v2.8.1/prometheus-2.8.1.linux-amd64.tar.gz

wget https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz

wget https://github.com/prometheus-community/postgres_exporter/releases/download/v0.10.1/postgres_exporter-0.10.1.linux-amd64.tar.gz

wget https://dl.grafana.com/enterprise/release/grafana-enterprise-8.4.1-1.x86_64.rpm

yum install grafana-enterprise-8.4.1-1.x86_64.rpm

server1:

下载完后解压包,修改配置文件prometheus.yml

ps. 修改过配置文件后需要重启服务

scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
    - targets: ['server1:9090']


  - job_name: 'agent1'
    static_configs:
    - targets: ['server2:9100']

  - job_name: 'postgrescn1'
    static_configs:
    - targets: ['server2:9187']


9090是prometheus server端口

可以登录web页面查看配置

9100是node端口,可通过https://node2:9100/metrics 查看配置

9187是postgres_node端口

ps. 内网需打隧道

grafana配置,端口为3000

PS. 默认账号密码:admin/admin

启动

server1:

[root@VM-96-39-centos prometheus-2.8.1.linux-amd64]# /data/prometheus-2.8.1.linux-amd64/prometheus --config.file="/data/prometheus-2.8.1.linux-amd64/prometheus.yml" &

grafana是用rpm装的,也可直接下tar包,启动方式不一样

server2:

nohup /data/node_exporter-1.3.1.linux-amd64/node_exporter &

export DATA_SOURCE_NAME="postgresql://dy:dy@@172.21.96.40:11345/postgres?sslmode=disable"
nohup /data/postgres_exporter-0.10.1.linux-amd64/postgres_exporter &

测试grafana监控数据库指标

配置数据源

import主机监控的模板

https://grafana.com/grafana/dashboards/8919

还有丰富的dashboards,可根据自己的需要导入,及安装对应的采集器。也可以自己定义面板,拷贝一份模板出来修改。
https://grafana.com/grafana/dashboards
https://github.com/percona/grafana-dashboards/releases

使用pg_bench 搞一些数据

这里使用的模板是https://grafana.com/grafana/dashboards/455


标签:exporter,postgresql,amd64,grafana,prometheus,https,com
来源: https://www.cnblogs.com/ddlearning/p/15913368.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有