Prometheus + Grafana 采集Windows主机监控数据
00 分钟
2021-7-2
2024-6-8
type
status
date
slug
summary
tags
category
icon
password
 

一、Prometheus

Prometheus(普罗米修斯)是一套比较完备的监控报警系统,其主要架构设计如图:
notion image

1. 主要是由以下组件构成:

 
  1. Prometheus server:服务中心,主要负责拉取和存储时序书库(Prometheus有自带的时序数据库)
  1. Client Libraries:客户端库,主要用于和具体的服务进行集成,采集监控数据,例如Micrometer
  1. Push gateway:另外一种数据push的采集方式(Prometheus默认使用pull的方式主动采集应用数据),用于适配一些没有长期稳定的进程   的服务
  1. Exporter:用于针对某些特定服务的数据采集工具,例如:mysql/kafka/HA等..
  1. Alert Manager:Prometheus的监控告警工具,主要通过webhook和其他告警系统进行集成告警,能够进行告警规则的配置
  1. 其他工具
同时,Prometheus也有一套自己的查询语法,用于已经采集的数据的结果查询,具体可以参考:
 

前言windows_exporter

windows_exporter是一个用于收集Windows操作系统指标的开源软件,它是Prometheus生态系统中的一个组件。类似于node_exporter,windows_exporter负责在Windows主机上运行,并公开各种与Windows系统相关的指标供Prometheus收集。
windows_exporter可以提供各种关于Windows主机的指标,如CPU使用率、内存使用情况、磁盘空间、网络流量、进程信息等。它还可以提供更详细的指标,如系统服务状态、Windows事件日志、性能计数器等。这些指标可以帮助系统管理员了解Windows主机的性能和健康状况,并及时采取措施来优化和修复问题。
类似于node_exporter,windows_exporter通过HTTP或者HTTPS暴露一个或多个端点,Prometheus会定期从这些端点拉取指标数据,并进行存储、分析和可视化。借助Prometheus的查询语言,用户可以根据这些指标来构建监控规则和警报条件,以便及时发现和解决Windows主机的问题。
 
通过Powershell一键安装windows_exporter监控数据采集
  • Windows操作系统采集(如CPU,内存,硬盘,网络等)
  • Windows 高版本建议安装最新的Windows_exporter
  • 采集端口9182
  • 防火墙不要关闭,防火墙规整默认安装完成会自动创建
 
 

执行一键安装

 
notion image
notion image
notion image
 

安装完成查看版本安装时间等等

  • 控制面板\所有控制面板项\程序和功能
notion image
 

自动生成的系统服务

  • 控制面板\所有控制面板项\管理工具\服务
notion image
 

访问采集信息

 
notion image

Prometheus 软件下载

安装普罗米修斯监控

Prometheus(由go语言(golang)开发)是一套开源的监控&报警&时间序列数据库的组合,适合监控docker容器和Windows服务器
下载并解压:prometheus-2.52.0.windows-amd64.zip
notion image
 
双击运行文件 prometheus.exe,会弹出如下cmd窗口,先不要关闭!不然访问不到
notion image
 
notion image
 
在prometheus.yml同级目录新建windows.yml
 
关闭并重启 prometheus.exe cmd窗口
打开 http://localhost:9090/targets,查看 windows状态为up即成功
 
notion image

Prometheus 采集配置

 

Grafana图形展示

Import>10467>Prometheus

 
 

prometheus监控 windows主机报警规则

 

Grafana

下载
notion image
 
解压 grafana-enterprise-10.4.0.windows-amd64.zip,解压后双击bin目录下 grafana-server.exe,弹出如下cmd窗口,不要关闭!
notion image
notion image
 
打开浏览器,访问 http://localhost:3000(账号密码默认是admin,首次登录要改新的密码)
(第一次访问端口可能会被占用,先关闭占用端口的应用程序)
notion image
登录进来,进入界面
notion image
创建数据源,关联 prometheus
notion image
输入 URL,其他默认即可
notion image
保存成功
notion image
 

选择 Grafana 模板

notion image
 
Download JSON(下载JSON模板文件到本地)
notion image
 
打开浏览器,访问 http://localhost:3000/dashboards,点击 Create Dashboard
notion image
 
点击 Import dashboard
notion image
 
导入下载的JSON模板文件,点击 Import
notion image
 
至此,监控系统配置完成
notion image

参考

 
上一篇
Ubuntu20.04 LTS安装 Docker及"gpg: 找不到有效的 OpenPGP 数据"解决方法
下一篇
Ubuntu22.04安装Docker两种方式