prometheus监控windows系统主机

prometheus监控windows系统主机
一、 windows_exporter的安装下载

  1. 安装包的下载
    windows_exporter
    官方下载地址:https://github.com/prometheus-community/windows_exporter/releases

2.windows_exporter下载完成后,双击即可运行。
默认端口是9182,在浏览器输入:localhost:9182即可打开如下页面。

为方便后续管理及使用,把windows_exporter注册为服务
3. 在注册表和服务数据库中创建windows_exporter服务项
sc create windows_exporter binpath= “C:\Program Files (x86)\windwos_exporter\windows_exporter-0.20.0-amd64.exe” type= own start= auto displayname= windows_exporter

注:binpath后接的是.exe程序所在的目录及程序名称

二、Prometheus增加windows_exporter配置

  1. 添加 prometheus.yml 配置: (需要注意文件格式)
  • job_name: “windwos_exporter”
    scrape_interval: 15s
    static_configs:
    • targets: [“192.168.2.93:9182”,“192.168.2.94:9182”]
  1. 检查windows_exporter节点
    重启prometheus,即可查看已经配置好的exporter

三,prometheus监控 windows主机报警规则

groups:
- name: WindwosService
  rules:
  - alert: WindowsServiceDown
    expr: wmi_service_state{state="running"} == 0
    for: 2m
    labels:
      team: node
    annotations:
      summary: "Host:{{$labels.instance}}; Service:{{$labels.name}} has been down 2 minutes!"
      description: "Host:{{$labels.instance}}; Service:{{$labels.name}} has been down 2 minutes!"
      value: "{{$value}}"


- name: WindowsMemUsageAlerts
  rules:
  - alert: Windows内存使用率
    expr: ((windows_cs_physical_memory_bytes - (windows_os_physical_memory_free_bytes)) /windows_cs_physical_memory_bytes) * 100 > 80
    for: 1m
    labels:
      status: warning
    annotations:
      summary: "{{ $labels.instance }} 内存使用大于80%(目前使用:{{$value}}%)"

- name: WindowsDiskUsageAlerts
  rules:
  - alert: WindowsDiskUsage
    expr: 100.0 - 100 * (windows_logical_disk_free_bytes / windows_logical_disk_size_bytes) > 85
    for: 5m
    labels:
      severity: warning
    annotations:
      summary: "磁盘使用率 {{ $labels.instance }} 大于 85% (目前使用: {{ $value }}%)"

groups:
- name: WindowsCPUUsageAlerts
  rules:
  - alert: Windows CPU使用率
    expr: 100 - (avg by (instance) (irate(windows_cpu_time_total{mode="idle"}[5m])) * 100) > 80
    for: 5m
    labels:
      severity: warning
    annotations:
      description: "High CPU usage on {{ $labels.instance }}"
      summary: "CPU使用率 {{ $labels.instance }} 大于 80% (current value: {{ $value }}%)"
      ```


  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值