Prometheus安装
下载下载Prometheus服务端
https://prometheus.io/download/
解压
tar -xvf prometheus-2.12.0.linux-amd64.tar.gz
cd prometheus-2.12.0.linux-amd64
运行
./prometheus --config.file="prometheus.yml"
访问服务器的9090端口
Prometheus安装完成
Grafana安装
https://grafana.com/docs/installation/rpm/
启动服务systemctl start grafana-server
Grafana安装完成
Prometheus被监控端安装插件
下载插件(此处下载一个node 和 mysql插件)
https://prometheus.io/download/
在被监控端主机解压这两个文件
node_exporter插件可直接运行
# cd node_exporter-0.18.1.linux-amd64
# ./node_exporter &
mysqld_exporter插件需要创建一个用户+密码的文件
# cd mysqld_exporter-0.12.1.linux-amd64
# cat .my.cnf
[client]
user=dbuser
password=Abc123..
#./mysqld_exporter --config.my-cnf=.my.cnf &
Prometheus被监控端安装插件完成
Prometheus服务端添加被监控端
cd prometheus-2.12.0.linux-amd64
# vim prometheus.yml
- job_name: system-status
static_configs:
- targets: ['172.16.60.124:9100','172.16.60.108:9100']
labels:
instance: 7-7
- job_name: mysql-status
static_configs:
- targets: ['172.16.60.124:9104']
labels:
instance: 7-7-mysql
Prometheus服务端添加被监控端完成
Grafana对接Prometheus
添加源数据
Grafana对接Prometheus完成
Grafana添加图表
https://grafana.com/grafana/dashboards
导入
导入时选择好对应的源
因饼图不显示 需要安装对应的插件
https://grafana.com/grafana/plugins/grafana-piechart-panel