Prometheus结合Grafana数据展示
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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
[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数据展示的主要内容,如果未能解决你的问题,请参考以下文章