grafana+prometheus监控服务器

背景


监控服务器状态是运维必不可少的一部分,这里给大家介绍的是一种监控系统grafana,grafana仅仅只是提供界面显示, 所以他需要从influxdb或prometheus中获取数据, 而influxdb或prometheus中的数据又需要从其他地方收集过来, 常用的收集工具是collectd和telegraf, 其中collectd这里不做介绍, 有些数据不是太适合, 而 influxdb 自身集成 telegraf插件, 不需要进行专门的配置

流程

collectd/telegraf或prometheus插件(收集数据) ——-> influxdb/prometheus(保存数据) ——-> grafana(显示数据)

下载node_exporter插件
1
wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-arm64.tar.gz
解压
1
tar xf node_exporter-*.tar.gz
在对应机器上启动node_exporter
1
setsid ./node_exporter
查看node_exporter是否开启
1
2
netstat -lntp
tcp6 0 0 :::9100 :::* LISTEN 62737/./node_export
修改prometheus配置文件
1
2
3
4
5
6
7
8
- job_name: 'node_exporter'
static_configs:
- targets: ['192.168.1.231:9100']
labels:
instance: sys-231
- targets: ['192.168.1.68:9100']
labels:
instance: sys-68
重启prometheus
1
nohup ./prometheus --config.file=./prometheus.yml &

grafana配置

配置prometheus数据源
添加prometheus插件,然后配置
Mou_icon
Mou_icon
Mou_icon

下载node_exporter仪表盘模板

Mou_icon

导入模板

Mou_icon
Mou_icon

坚持原创技术分享,您的支持将鼓励我继续创作!