有项目做测试的时候需要查询服务器资源利用情况,自己又没写相应的模块,此时就需要一套好用的资源监控系统,,咨询了运维人员给推荐了一套,装完后真的很好用。
就是grafana+prometheus+node_exporter(linux)或者windows_exporter(wins)
具体介绍不多说:
1、grafana是对数据做展示用的,各种图表方式;
2、prometheus是拉取、整合监控数据的;
3、node_exporter是被监控服务器上或者监控指标数据的。
具体使用步骤如下:
需要在被监控的linux服务器安装node_exporter、wins服务器安装windows_exporter,然后找一台网络通的局域网装上grafana+prometheus进行监控数据查看,以下步骤按照在wins上安装grafana+prometheus的步骤,有linux的同学需要自行再查找。
一、安装软件
1、下载prometheus, Download | Prometheus
2、下载grafana, Download Grafana | Grafana Labs
如果太慢可以从Grafana 国内加速下载 | newbe下载
3、下载node_exporter(linux) Download | Prometheus
如果是wins操作系统,则从 Releases · prometheus-community/windows_exporter · GitHub
下载完成后正常安装,然后查看是否安装成功:
测试方法,wins安装后通过http://127.0.0.1:9182/metrics 是否有数据,linux通过http://127.0.0.1:9100/metrics 两个端口都是默认端口,ip地址为被监控的服务器ip
二、配置启动服务
4、在prometheus安装包里面有一个配置文件prometheus.yml,打开后在static_configs节点下配置需要监控的服务器安装的node_exporter或者windows_exporter服务

5、在prometheus安装包双击prometheus.exe启动,在grafana安装包下bin目录下,双击grafana-server.exe启动;启动完的小黑框不能关
三、管理页面配置
6、通过http://127.0.0.1:9090访问prometheus管理页面,查看被监控的资源是否加入

如果出现以下节点,说明加入成功 ,此步骤只是确认资源是否加入。

7、访问http://127.0.0.1:3000访问grafana
配置数据源,就是将监控的数据拉取到grafana,进行图表展示
选择展示模板进行监控数据查看







特别注意: 选择模板json的时候一定要区分wins和linux操作系统,两个不能公用模板
我找的wins的id是:14694 linux的id是1860,需要其它的可从下面模板地址查找