运维开发网

一、Prometheus结合Grafana数据展示

运维开发网 https://www.qedev.com 2020-10-25 12:47 出处:51CTO 作者:XiaoMingSix
部署Prometheus结合Grafana数据展示

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
[[email protected] 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

一、Prometheus结合Grafana数据展示

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

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

一、Prometheus结合Grafana数据展示

查看监控成果

一、Prometheus结合Grafana数据展示

扫码领视频副本.gif

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号