grafana+prometheus+node_exporter
2021-01-29 本文已影响0人
陈芝麻烂谷子的事
前言:
性能测试过程中对于服务器各项指标的监控尤为重要,一套好用的监控工具可以给整个复杂的性能测试过程带来很多便利。包含随着业务的越发复杂,如何实现服务的监控有效的观测服务器各项指标也显得尤其重要,由此找到grafana+prometheus+node_exporter的工具组合实现服务器性能的可视化的监控工作。
一、工具关系结构图:

二、工具的安装使用:
1.node_exporter的安装与使用
(1)安装系统linux。
(2)下载和启动方式:
命令:
wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
解压:
tar xzvf node_exporter-0.18.1.linux-amd64.tar.gz
启动:
cd node_exporter-0.18.1.linux-amd64
./node_exporter
(3)启动效果:

2.prometheus的安装与使用:
(1)下载:https://prometheus.io/download/
根据自己所需的系统版本下载即可,这里下载的wondows版本(windows-amd64)
(2)本地解压下载的文件夹,打开文件prometheus.yml,在文件的末尾增加监测的ip和端口,需要监测多个服务器时使用逗号隔开,效果如图所示:

(3)启动应用查看是否监控成功:启动prometheus.exe,然后通过浏览器访问:localhost:9090。

点击status - Targets进入监控到的服务器信息列表:

出现已经配置好的服务器信息代表成功,效果图如下:

3.grafana的安装与使用:
(1)下载:https://grafana.com/grafana/download
可根据自己的诉求下载相应系统下的版本,这里使用的是windows版本
(2)启动:本地访问localhost:3000,默认的账号密码admin/admin,登录成功后如图所示:

(3)新增prometheus数据源,用于获取permetheus读取的系统信息数据。
点击如图所示位置进入数据源新增页面:

点击Add data source:

选择Prometheus:

填入url为本地permetheus的地址,点击save&test

(4)新增一个监控模板,步骤如下:
进入grafana官网 https://grafana.com/
从菜单栏Grafana中选择Dashboards,进入dashboards模板页面,复制ID,这里用的是8919,在grafana上import 监听模块,如图所示:

Name为监控仪表盘的名称;VictoriaMetrics为数据源,选择之前新增的permetheus数据源即可;最后点击import:

最终完成监控的配置:
