【Windows 10】Prometheus监控平台安装以及配置windows Exporter探针

Prometheus

简介

Prometheus是一个开放性的监控解决方案,用户可以非常方便的安装和使用Prometheus并且能够非常方便的对其进行扩展。
在Prometheus的架构设计中,Prometheus Server并不直接服务监控特定的目标,其主要任务负责数据的收集,存储并且对外提供数据查询支持。因此为了能够能够监控到某些东西,如主机的CPU使用率,我们需要使用到Exporter。Prometheus周期性的从Exporter暴露的HTTP服务地址(通常是/metrics)拉取监控样本数据。
Exporter可以是一个相对开放的概念,其可以是一个独立运行的程序独立于监控目标以外,也可以是直接内置在监控目标中。只要能够向Prometheus提供标准格式的监控样本数据即可。

更详细的文档请戳:Prometheus 中文文档

Prometheus下载安装

下载地址:https://prometheus.io/download/
在这里插入图片描述
下载完成后,解压压缩包,直接运行prometheus.exe即可。

访问Prometheus

prometheus默认端口是9090,在浏览器输入:localhost:9090即可访问。
在这里插入图片描述

也可以在prometheus.yaml中修改默认端口。
在这里插入图片描述

Windows Exporter

下载安装

Windows Exporter 由 Prometheus Community 维护,官方地址是:https://github.com/prometheus-community/windows_exporter 。 当前版本是 v0.18.0 ,发行于 2022.02.05 。

Windows Exporter 是一个采集 Windows 机器指标的采集器。支持 Windows Server 2008R2 以上版本或者 Windows 7 以上版本。

Windows Exporter 在发布的是时候提供了两种格式的文件,分别是 *.exe 和 *.msi 。

MSI (Microsoft Installers)是 Windows 的包管理器,类似于 Linux 的 rpm 。

Windows Exporter 每个版本都提供一个 .msi 安装程序。安装程序将 windows_exporter 设置为 Windows 服务,并在 Windows 防火墙中创建一个异常。

我们在使用的时候可以选择任意一种格式来进行安装。

下载地址:https://github.com/prometheus-community/windows_exporter/releases
在这里插入图片描述
下载完成后,管理员直接运行windows_exporter-0.18.1-amd64.exe文件即可。

访问Windows Exporter

windows_exporter默认端口是9182,在浏览器输入:localhost:9182即可访问。
在这里插入图片描述

采集的指标

这个列表是 Windows Exporter 支持采集的指标,有一些指标是启动后缺省会打开的,有一些是需要手动打开的。
https://github.com/prometheus-community/windows_exporter

名称说明是否默认开启
adActive Directory Domain Services×
adcsActive Directory Certificate Services×
adfsActive Directory Federation Services×
cacheCache metrics×
cpuCPU usage
cpu_infoCPU Information×
cs“Computer System” metrics(system properties, num cpu / total memory)
containerContainer metrics×
dfsrDFSR metrics×
dhcpDHCP Server×
dnsDNS Server×
exchangeExchange metrics×
hypervHyper-V hosts×
iisIIS sites and applications×
logical_diskLogical disks, disk I/O
logonUser logon sessions×
memoryMemory usage metrics×
msmqMSMQ queues×
mssqlSQL Server Performance Objects metrics×
netframework_clrexceptions.NET Framework CLR Exceptions×
netframework_clrinterop.NET Framework Interop Metrics×
netframework_clrjit.NET Framework JIT metrics×
netframework_clrloading.NET Framework CLR Loading metrics×
netframework_clrlocksandthreads.NET Framework locks and metrics threads×
netframework_clrmemory.NET Framework Memory metrics×
netframework_clrremoting.NET Framework Remoting metrics×
netframework_clrsecurity.NET Framework Security Check metrics×
netNetwork interface I/O
osOS metrics (memory, processes, users)
processPer-process metrics×
remote_fxRemoteFX protocol (RDP) metrics×
serviceService state metrics
smtpIIS SMTP Server×
systemSystem calls
tcpTCP connections×
timeWindows Time Service×
thermalzoneThermal information×
terminal_servicesTerminal services (RDS)×
textfileRead prometheus metrics from a text file
vmwarePerformance counters installed by the Vmware Guest agent×

使用配置文件

Windows Exporter 支持使用 --config.file 参数来指定一个 YAML 格式的文件作为配置文件来启动,比如: .\windows_exporter.exe --config.file=config.yml .
这个配置文件支持配置要采集的内容,日志、等内容。

Prometheus配置exporter

打开prometheus的配置文件:
在这里插入图片描述
在prometheus.yaml中加上如下内容:

	- job_name: “windows_exporter”
	
	# you can customize the job name’.
	  static_configs:
		- targets: ["localhost:9182", "10.47.38.66:9182", "10.47.38.62:9182"]

在这里插入图片描述

重启prometheus即可查看已经配置好的exporter。
在这里插入图片描述

了解更多的Exporter

关于Exporter的介绍可以看这篇文章,介绍的非常详细。
https://xie.infoq.cn/article/230d2f31f102259dfe821519f

### 回答1: 可以使用PrometheusWindows Exporter监控Windows批处理脚本,该Exporter会收集服务器上的性能指标,并将其发送到Prometheus服务器,以便Prometheus可以对其进行监控。 ### 回答2: Prometheus是一种开源的监控解决方案,Windows_exporterPrometheus的一个工具,用于监控Windows操作系统的指标。要使用Windows_exporter监控批处理脚本,可以按照以下步骤进行操作: 1. 下载和安装Windows_exporter:访问Windows_exporter的GitHub页面,下载最新的可执行文件。 2. 配置Windows_exporter:在Windows_exporter安装目录下,创建一个配置文件(如windows_exporter.yml),并配置监控的批处理脚本的相关信息,例如脚本的路径等。 3. 启动Windows_exporter:使用管理员权限打开命令提示符,并导航到Windows_exporter安装目录,执行以下命令启动Windows_exporter: ``` windows_exporter.exe --collector.batchfile.path="Path\to\script.bat" --config.windows_exporter.yml ``` 其中,--collector.batchfile.path参数指定要监控的批处理脚本的路径,--config.windows_exporter.yml参数指定配置文件的路径。 4. 配置Prometheus:在Prometheus配置文件(prometheus.yml)中添加一个新的job,用于抓取Windows_exporter提供的指标。示例如下: ```yaml - job_name: 'windows' static_configs: - targets: ['localhost:9182'] ``` 其中,'localhost:9182'是Windows_exporter默认的监听地址,可根据实际情况进行修改。 5. 重启Prometheus:保存并关闭Prometheus配置文件,重启Prometheus服务,使其能够加载新的配置。 6. 查看监控指标:访问Prometheus的Web界面,可以通过查询PromQL语句来查看和分析批处理脚本的监控指标。例如,查询批处理脚本执行次数的指标可以使用以下PromQL语句: ``` script_batchfile_total{job="windows"} ``` 通过这些步骤,您可以使用Windows_exporter监控批处理脚本,并通过Prometheus来收集和分析这些监控指标。 ### 回答3: Prometheus是一个开源的监控系统,可以用于监控各种应用、服务和服务器。Windows_exporterPrometheus的一个插件,可以用于监控Windows系统的各种指标。 要使用windows_exporter监控批处理脚本,首先需要在Windows系统上安装配置Prometheuswindows_exporter。可以到Prometheus官方网站上下载最新版本的Prometheus,并按照文档中的步骤进行安装配置安装Prometheus后,需要下载并安装windows_exporter。在windows_exporter的GitHub页面上可以找到最新的发布版本。下载后,将windows_exporter解压到一个合适的目录。 接下来,需要创建一个用于监控批处理脚本的配置文件。在Prometheus配置文件(prometheus.yml)中添加以下内容: ```yaml scrape_configs: - job_name: 'my_batch_scripts' static_configs: - targets: ['localhost:9182'] ``` 其中,job_name可以自定义,targets是windows_exporter的默认监听端口。 保存并关闭配置文件后,需要启动Prometheuswindows_exporter。在命令行中导航到Prometheus安装目录,执行以下命令启动Prometheus: ``` prometheus.exe --config.file=prometheus.yml ``` 再打开一个新的命令行窗口,导航到windows_exporter安装目录,执行以下命令启动windows_exporter: ``` windows_exporter.exe ``` 启动后,Prometheus将开始收集和存储windows_exporter提供的所有指标。可以通过Prometheus的Web界面(默认为localhost:9090)查看和查询这些指标。 接下来,可以根据批处理脚本的需要,编写相关的指标规则和警报规则。通过Prometheus的查询语言和警报规则语言,可以实现对批处理脚本的监控和告警。 总结来说,要使用windows_exporter监控批处理脚本,需要安装配置Prometheuswindows_exporter,创建一个用于批处理脚本的配置文件,启动Prometheuswindows_exporter,并进行指标和警报规则的配置。通过Prometheus的Web界面进行监控和查询。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值