码迷,mamicode.com
首页 > 其他好文 > 详细

一、Prometheus结合Grafana数据展示

时间:2020-10-24 11:44:28      阅读:31      评论:0      收藏:0      [点我收藏+]

标签:lib   fail   数据源   ice   restart   job   tar   mic   star   

1.安装prometheus服务端
#下载软件包
wget https://github.com/prometheus/prometheus/releases/download/v2.21.0/prometheus-2.21.0.linux-amd64.tar.gz

#解压
tar xf prometheus-2.21.0.linux-amd64.tar.gz -C /opt/
cd /opt/
mv prometheus-2.21.0.linux-amd64 prometheus

#配置systemctl启动
cat > /usr/lib/systemd/system/prometheus.service <<EOF
[Unit]
Description=https://prometheus.io
[Service]    
Restart=on-failure
ExecStart=/opt/prometheus/prometheus --config.file=/opt/prometheus/prometheus.yml
[Install]
WantedBy=multi-user.target
EOF

#启动prometheus
systemctl daemon-reload
systemctl start prometheus

#检查监听端口9090
[root@master opt]# netstat -lntup|grep 9090

#浏览器访问http://ip:9090主界面

2.安装node_exporter客户端

#下载软件包
wget https://github.com/prometheus/node_exporter/releases/download/v1.0.1/node_exporter-1.0.1.linux-amd64.tar.gz

#解压
tar xf node_exporter-1.0.1.linux-amd64.tar.gz -C /opt/
cd /opt
mv node_exporter-1.0.1.linux-amd64 node_exporter

#配置systemctl启动
cat > /usr/lib/systemd/system/node_exporter.service <<EOF
[Service]
User=root
Group=root
ExecStart=/opt/node_exporter/node_exporter
[Install]
WantedBy=multi-user.target
[Unit]
Description=node_exporter
After=network.target
EOF

#启动node_exporter
systemctl start node_exporter
#检查监听端口9100
netstat -lntup|grep 9100

3.服务端监控客户端

#修改prometheus.yml配置文件,新增如下功能
vim /opt/prometheus/prometheus.yml
  - job_name: ‘node1‘
    static_configs:
    - targets: [‘192.168.223.132:9100‘]

  - job_name: ‘node2‘
    static_configs:
    - targets: [‘192.168.223.133:9100‘]

#重启
systemctl restart prometheus

4.部署grafana平台

#安装
wget https://dl.grafana.com/oss/release/grafana-5.3.4-1.x86_64.rpm
yum -y install grafana-5.3.4-1.x86_64.rpm
#启动
systemctl start grafana-server 
systemctl enable grafana-server

#检查监听端口3000
netstat -lntup|grep 3000
#浏览器访问http://ip:3000主界面,用户名密码 admin / admin
#配置prometheus数据源

5.Grafana添加prometheus数据源

Dashboard——>HOME——>Create your first data source

技术图片

6.添加第一个Grafana监控模板

Dashboard——>Manage——>import Dashboard :9276

技术图片

查看监控成果

技术图片

一、Prometheus结合Grafana数据展示

标签:lib   fail   数据源   ice   restart   job   tar   mic   star   

原文地址:https://blog.51cto.com/dropak/2542963

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!