grafana+prometheus+windows_exporter实现windows进程资源占用的监控

grafana+prometheus+windows_exporter实现windows进程资源占用的监控@TOC

一、 管理端搭建,采用windows版本的grafana+prometheus

管理端安装部署不做本文终端,简单讲解一下,此处采用msi的grafana安装包,和免安装版本的prometheus

1.下载安装grafana

下载地址:https://grafana.com/grafana/download

  1. 安装grafana

直接下载安装包双击安装即可,此处不做特殊设置不做重点讲

  1. 管理端访问grafana

打开本机浏览器直接访问127.0.0.1:9090

默认账号admin 默认密码 admin

  1. prometheus下载

下载地址:https://prometheus.io/download/

  1. prometheus安装

免安装版本,直接解压到一个方便的运行目录即可

  1. 配置prometheus配置文件

文件名称prometheus.yml,与prometheus.exe同级,新增本机9182端口,如图(注意配置文件的缩进必须一致)

  1. 启动prometheus

双击prometheus.exe启动,注意小黑窗不能关闭,切每次修改配置文件后都要手动重启下prometheus才能生效(有不用重启的配置方式)

  1. 访问prometheus

浏览器中访问127.0.0.1:9090,即可访问

访问http://127.0.0.1:9090/targets,可以查看配置的采集设备,如果设备连接正常,会显示绿色,如图:

  1. 在grafana中新增数据源

在grafana的Configuration页面(http://127.0.0.1:3000/datasources) 新增一个数据源,新增时选择prometheus,进修改下URL即可,配置页面如下:

配置后保存。

  1. grafana导入模板

此内容是本次讲解内容,后免讲。

二、 终端采集器安装和配置

采用标准的windows_exporter,然后进行配置process监控

  1. windows_exporter下载最新版本

    下载地址:https://github.com/prometheus-community/windows_exporter/releases/tag/v0.29.2

    此处下载选择:msi安装包

  2. 双击msi安装包安装

    直接安装即可,如果修改了安装目录需要记住安装路径,默认路径(C:\Program Files\windows_exporter)

  3. 浏览访问

    浏览器访问:http://127.0.0.1:9182/metrics 查看是否启动(启动失败查看进程是否启动)

  4. 修改exporter的配置文件

    前往windows_exporter的安装目录(默认C:\Program Files\windows_exporter),新建文件config.yaml(如果已经存在则直接修改)

    编辑config.yaml文件,在文件中新增:

    复制代码
    collectors:
      enabled: cpu,cs,logical_disk,net,os,service,system,textfile,process

    其中cpu,cs,logical_disk,net,os,service,system,textfile是默认监控的,新增一个process,开启进程监控

    如下图

  5. 重启windows_exporter服务

    在进程管理中重启windows_exporter,默认为自动启动,重启后配置文件生效

    重启后再次访问http://127.0.0.1:9182/metrics

    查看页面底部是否出现process进程相关数据,如果有则证明操作生效

三、 管理端grafana中新增进程模板

  1. windows进程模板下载

    地址:https://grafana.com/grafana/dashboards/13262-services-processes/

    模板编号13262

  2. grafana中导入新模板

    登录grafana,Import dashboard http://127.0.0.1:3000/dashboard/import

    upload JSON file 选择刚才下载的json模板文件(联网下可以直接输入模版号load)

    Prometheus选择之前添加的本地Prometheus

    点import提交

  3. 打开新增的模板

    一般新增完会直接跳转到新增的模板

    在Search dashboards by name http://127.0.0.1:3000/dashboard/import?search=open中根据名称找到刚才新增的模板

  4. 查看进程数据

    前面配置没有问题的话,稍等一会即可看到数据,如果等不及可以调整一下右上角的取样时间段和刷新时间,建议查看最近5分钟,5秒刷新一次

    完毕

四、 参考及其其他相关文章

https://blog.csdn.net/csdn_chenhao/article/details/128034399

https://www.apispace.com/news/post/18997.html

相关推荐
云徒川8 小时前
【设计模式】过滤器模式
windows·python·设计模式
virelin_Y.lin9 小时前
系统与网络安全------Windows系统安全(4)
windows·web安全·系统安全·账号安全
学也不会11 小时前
d202541
windows
厦门德仔12 小时前
【C#】C#字符串拼接的6种方式及其性能分析对比
服务器·windows·c#
企鹅侠客14 小时前
Prometheus operator怎么添加targets和告警规则
运维·云原生·kubernetes·prometheus·pod
网络探索者18 小时前
DirectX修复工具(DirectX Repair)官网免费下载
windows
心灵宝贝19 小时前
SQLyog一款被遗忘的MySQL管理利器深度解析
windows
Doris Liu.1 天前
如何检测代码注入(Part 2)
windows·python·安全·网络安全·网络攻击模型
bjxiaxueliang1 天前
一文详解QT环境搭建:Windows使用CLion配置QT开发环境
开发语言·windows·qt
郁大锤1 天前
如何在 Windows 上安装与配置 Tomcat
java·windows·tomcat