Prometheus windows_exporter 部署

文章指导如何下载并安装windows_exporter,通过创建Windows服务进行设置。启动服务后,用户可以通过浏览器访问指定端口(如9182)查看metrics数据。

Prometheus windows_exporter

安装包下载

Prometheus 官网下载地址
包含Prometheus软件及各种exporter插件

windows_exporter安装包

注册服务

win+R cmd
dos窗口中创建服务

sc create windows_exporter binpath= "C:\Program Files\windows_exporter\windows_exporter.exe" start= auto displayname= windows_exporter

在windows服务中开启windows_exporter服务
web页面查看

浏览器访问 服务器地址+端口号默认端口9182

例如 http://192.168.1.21:9182/

在这里插入图片描述

Metrics可查看所有指标数据

在容器化与云原生日益普及的今天,手动部署 Prometheus 生态组件步骤繁琐且易出错,可借助 Ansible 实现自动化部署。要使用 Prometheus、Ansible 和 Windows Exporter 实现监控自动接入,可按以下步骤操作: ### 环境准备 确保已经安装好 Ansible、Prometheus 服务器,并且要监控的 Windows 主机可以被 Ansible 管理,同时在 Prometheus 服务器能够访问到 Windows 主机。 ### 安装 Windows Exporter 在 Ansible 控制节点上编写 playbook 来安装 Windows Exporter。以下是一个简单的示例: ```yaml --- - name: Install Windows Exporter hosts: windows_servers gather_facts: false tasks: - name: Download Windows Exporter win_get_url: url: https://github.com/prometheus-community/windows_exporter/releases/download/v<version>/windows_exporter-<version>.amd64.msi dest: C:\temp\windows_exporter.msi - name: Install Windows Exporter win_package: path: C:\temp\windows_exporter.msi state: present ``` 其中 `<version>` 需要替换为实际的 Windows Exporter 版本号。 ### 配置 Windows Exporter 同样使用 Ansible 来配置 Windows Exporter,让其正常运行并暴露指标接口。可以编写如下 playbook: ```yaml --- - name: Configure Windows Exporter hosts: windows_servers gather_facts: false tasks: - name: Create configuration directory win_file: path: C:\Program Files\windows_exporter\config state: directory - name: Copy configuration file win_copy: src: /path/to/config.yml dest: C:\Program Files\windows_exporter\config\config.yml - name: Restart Windows Exporter service win_service: name: windows_exporter state: restarted ``` 这里的 `/path/to/config.yml` 是本地的 Windows Exporter 配置文件路径。 ### 配置 PrometheusPrometheus 的配置文件 `prometheus.yml` 中添加对 Windows Exporter 的监控配置。可以使用 Ansible 来更新这个配置文件: ```yaml --- - name: Configure Prometheus hosts: prometheus_server gather_facts: false tasks: - name: Update Prometheus configuration blockinfile: path: /etc/prometheus/prometheus.yml block: | - job_name: 'windows_exporter' static_configs: - targets: ['<windows_host_ip>:9182'] marker: "# {mark} ANSIBLE MANAGED BLOCK - WINDOWS EXPORTER" - name: Restart Prometheus service systemd: name: prometheus state: restarted ``` `<windows_host_ip>` 需要替换为实际的 Windows 主机 IP 地址。 ### 验证监控接入 访问 Prometheus 的 Web 界面(通常是 `http://<prometheus_server_ip>:9090`),在 `Status -> Targets` 页面查看 Windows Exporter 的状态是否为 `UP`。如果是,则表示监控自动接入成功。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

为什么不问问神奇的海螺呢丶

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值