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

相关推荐
阿尼卡~18 小时前
VS Code 配置 C 语言开发环境(Windows 10/11):从 GCC 安装到运行、断点调试,一篇搞定
c语言·开发语言·windows
liyi_hz20081 天前
O2OA(翱途) V10.1 即将发布|功能再升级,安全再加固,协同更高效!
java·javascript·windows·开源软件
七牛云行业应用1 天前
DeepSeek Harness(dsh)安装完整指南:Windows、macOS、Linux 三平台 + 桌面端与 Web 端全覆盖
linux·windows·macos·ai·ai编程
起个名字都难啊1 天前
visual studio C/C++空项目修改为CUDA c++
c++·windows·visual studio
xixiaoyunya1 天前
轻量级 Windows 文件共享方案实测:零配置部署私有网盘,兼容全平台浏览器访问
windows
垆边人似月.1 天前
第二篇:列表、字典与流程控制 / Lists, Dictionaries & Control Flow
windows
呉師傅1 天前
Win7剪切文件变成复制文件如何修改【资源管理器异常类故障】
运维·网络·windows·电脑
略略略咯咯1 天前
33333
开发语言·windows·python
2501_915918411 天前
Windows 上开发 React Native iOS,真机调试、Fast Refresh 与打包 ipa
windows·vscode·react native·ios·个人开发·swift·敏捷流程
LannyChung2 天前
PowerShell 下 git log 中文乱码的完整排查与解决
windows·git