《云原生监控体系构建实录:从Prometheus到Grafana的观测革命》 ...

打印 上一主题 下一主题

主题 970|帖子 970|积分 2910

Prometheus+Grafana摆设配置
Prometheus安装

下载Prometheus服务端

Download | PrometheusAn open-source monitoring system with a dimensional data model, flexible query language, efficient time series database and modern alerting approach.
https://prometheus.io/download/


上传至服务器,解压
  1. tar -zxvf prometheus-3.0.1.linux-amd64.tar.gz
复制代码

  1. cd prometheus-3.0.1.linux-amd64
复制代码

运行
  1. ./prometheus --config.file="prometheus.yml"
复制代码
后台运行
  1. nohup ./prometheus --config.file=prometheus.yml &
复制代码

当首次访问9090端口时,时间序列数据的洪流如同宇宙背景辐射般劈面而来。


Grafana安装

Grafana是一个可视化面板(Dashboard),有着非常美丽的图表和布局展示,功能齐备的度量仪表盘和图形编辑器,支持Graphite、zabbix、InfluxDB、Prometheus
下载地址:Download Grafana | Grafana LabsOverview of how to download and install different versions of Grafana on different operating systems.
https://grafana.com/grafana/download

  1. yum localinstall -y grafana-6.5.0-1.x86_64.rpm
复制代码

  1. systemctl start grafana-server
复制代码
访问页面http://服务器IP:3000 ,默认账号、暗码admin/admin



Prometheus被监控端安装插件

下载插件(此处下载一个node 和 mysql插件)
Download | PrometheusAn open-source monitoring system with a dimensional data model, flexible query language, efficient time series database and modern alerting approach.
https://prometheus.io/download/

在被监控端主机解压这两个文件
  1. tar -zxvf node_exporter-1.8.2.linux-amd64.tar.gz 
复制代码
           
  1. node_exporter插件可直接运行
  2. cd node_exporter-1.8.2.linux-amd64
复制代码
node_exporter插件可直接运行
cd node_exporter-1.8.2.linux-amd64

nohup ./node_exporter &

   mysqld_exporter必要连接到MySQL,必要授权
  
  mysqld_exporter插件必要创建一个用户+暗码的文件
  1. tar -zxvf mysqld_exporter-0.16.0.linux-amd64.tar.gz
复制代码

  1. cd mysqld_exporter-0.16.0.linux-amd64
复制代码

  1. mysql> use mysql;
  2. mysql> create user dbuser;
复制代码

  1. mysql> GRANT REPLICATION CLIENT, PROCESS ON *.* TO 'dbuser'@'localhost' identified by '123456';
复制代码

  1. mysql> GRANT SELECT ON performance_schema.* TO 'dbuser'@'localhost';
复制代码


创建 .my.cnf 参加以下内容
  1. [client]
  2. user=dbuser
  3. password=123456
复制代码

启动mysqld_exporter
  1. nohup ./mysqld_exporter --config.my-cnf=.my.cnf &
复制代码

Prometheus服务端添加被监控端


  1. cd prometheus-3.0.1.linux-amd64
复制代码
  1. vi prometheus.yml  加入
  2.   - job_name: system-status
  3.     static_configs:
  4.     - targets: ['192.168.126.50:9100']
  5.       labels:
  6.         instance: 7-7
  7.   - job_name: mysql-status
  8.     static_configs:
  9.     - targets: ['192.168.126.40:9104']
  10.       labels:
  11.         instance: 7-7-mysql
复制代码

  1. ​访问Prometheus   http://192.168.126.30:9090/targets
复制代码



Grafana对接Prometheus

添加源数据





添加乐成
Grafana添加图表
自带dashboard




下载地址
Grafana dashboards | Grafana LabsBrowse a library of official and community-built dashboards.
https://grafana.com/grafana/dashboards


导入








免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

用户国营

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表