前言
node_exporter是采集器,把采集到的数据存储到prometheus数据库,然后grafana取数据库里面的数据,进行展示;
一、使用步骤
1.下载安装启动prometheus
下载地址:https://prometheus.io/download/
1、选择自己需要的版本
2、本地直接无脑安装-进入到安装目录中
3、双击启动, 访问localhost:9090, 到此prometheus安装成功.
2.下载安装启动node_exporter
1、该包需要安装到需要监控的服务器上
mkdir /data/prometheus
cd /data/prometheus
wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
tar -zxvf node_exporter-0.18.1.linux-amd64.tar.gz
cd node_exporter-0.18.1.linux-amd64
#启动
nohup ./node_exporter>node.logs 2>&1 &
2、通过服务器IP+端口访问
http://{ip}:9100/metrics
3、如图所示说明安装成功
3、配置prometheus.yml文件
1、新增配置
复制这部分代码到文件中修改上面配置的服务器的IP,端口号默认是9100(不建议修改端口号)
- job_name: 'node_exporter-1'
static_configs:
- targets: ['192.***.***:9100']
2、重启prometheus
重启完后
运行
http://localhost:9090/targets
出现如下页面说明配置成功
4、下载安装grafana
地址:https://grafana.com/grafana/download/8.0.3?edition=oss
1、直接无脑安装(安装步骤忽略)
sudo /bin/systemctl start grafana-server.service
验证步骤输入如下:
http://localhost:3000/
默认账号密码:admin/admin 绑定prometheus,
2、点击data sources然后点击add data sources
3、增加模板,点击manage并点击import
4、输入8919并点击load 选择需要使用模板的prometheus
二、总结
grafana+prometheus+node_exporter 记录大概步骤后续再补充