实时监控Windows服务器:使用Prometheus和Grafana的终极方案

1. 下载并安装 Prometheus

  1. 下载 Prometheus

    • 访问 Prometheus 下载页面
    • 下载适用于 Windows 的压缩包(.zip 文件)。
    • prometheus-2.53.2.windows-amd64.zip 下载其中一个就行
  2. 安装 Prometheus

    • 解压下载的压缩包到你选择的目录(例如 C:\prometheus)。
  3. 配置 Prometheus

    • C:\prometheus 目录下找到 prometheus.yml 文件。打开并编辑该文件,配置你的 scrape 目标。可以使用如下配置:
yml 复制代码
# my global config
global:
  scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: "prometheus"

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ["localhost:9090"]
# 监控应用1:metrics
  - job_name: "windows"
    file_sd_configs:
    - refresh_interval: 15s
      files: 
      - ".\\windows.yml"
  • 保存并关闭 prometheus.yml 文件。
  1. 启动 Prometheus
    • 导航到 C:\prometheus 目录下找到prometheus.exe
    • 双击运行即可
    • 默认情况下,Prometheus 将在 http://localhost:9090/graph 上运行,点击即可!。

2. 下载并安装 Grafana

  1. 下载 Grafana

    • 访问 Grafana 下载页面

    • 下载grafana-enterprise-11.1.3.windows-amd64.zip 选择目录解压。

  2. 启动 Grafana

    • bin目录双击 grafana-server.exe

    • 默认情况下,Grafana 将在 http://localhost:3000 上运行。

    • 启动 Grafana 后,打开浏览器并访问 http://localhost:3000

    • 默认登录用户名和密码是 admin,首次登录后会提示你更改密码。

3. 下载并配置 windows_exporter

  1. 下载 windows_exporter

  2. 安装 windows_exporter

    • 解压下载的文件到你选择的目录(例如 C:\windows_exporter)。
  3. 启动 windows_exporter

    • 双击windows_exporter-0.27.1-amd64.exe
    • 默认情况下,windows_exporter 将在 http://localhost:9182/metrics 上运行。

4. 配置 Prometheus

  1. 更新 prometheus.yml 文件
    • 确保 prometheus.yml 文件中的 targets 配置正确指向 windows_exporter,如:
yaml 复制代码
# 监控应用1:metrics
  - job_name: "windows"
    file_sd_configs:
    - refresh_interval: 15s
      files: 
      - ".\\windows.yml"
  • 保存并关闭文件。
  • 目录新建 windows.yml 文件
yml 复制代码
- targets: ["127.0.0.1:9182"]
  labels:
    instance: 127.0.0.1
    serverName: '本地Windows服务器'
  • 保存并关闭 windows.yml 文件。
  1. 重启 Prometheus
    • 如果 Prometheus 已经在运行,请重新启动以应用新的配置。

5. 配置 Grafana

  1. 添加 Prometheus 数据源

    • 登录 Grafana 后,点击左侧菜单中的 "⚙️ (Configuration)" 图标,然后选择 "Data Sources"。

    • 点击 "Add data source",选择 "Prometheus"。

    • 在 "HTTP" 部分的 "URL" 字段中输入 http://localhost:9090

    • 点击 "Save & Test" 按钮确认数据源配置是否成功。

  2. 创建仪表盘

    • 在左侧菜单中点击 "+ (Create)",选择 "Dashboard"。
  • 点击 查找并导入常见应用程序的仪表板
  • 搜索 windows

下载:Windows Exporter Dashboard 20230531-StarsL.cn

是一个json

  • 导入刚刚下好的json文件
  • 点击导入即可
  • 点击保存

这个就是:windows_exporter-0.26.0-amd64 收集过来的指标数据!

敬请期待...

汉化Grafana

监控Spring boot应用,使用Grafana监控该系统

自定义指标

Grafana可视化大屏展示自己定义的指标数据

alertmanager报警

监控自己的MySQL数据库指标

相关推荐
likfishdn1 分钟前
Linux的文件与目录管理
linux·运维·服务器
渲染101专业云渲染3 分钟前
川翔云电脑优势总结
服务器·3d·电脑·blender·maya
2501_9032386512 分钟前
Git Bash:Windows下的强大命令行工具
windows·git·bash·个人开发
chian-ocean21 分钟前
Linux 文件缓冲区:高效数据访问的幕后推手
linux·运维·服务器
加油=^_^=22 分钟前
【Linux】进程优先级 | 进程调度(三)
linux·运维·服务器
橘子味的茶二32 分钟前
高级系统架构师--第十章:计算机网络
服务器·计算机网络·系统架构
吃汤圆的抹香鲸1 小时前
GoLand 安装包 绿色版 Win,Mac,Linux 包含IntelliJ全家桶 专为Go语言设计的集成开发环境(IDE)
linux·windows·macos·go·intellij-idea·go1.19
紫菜(Nori)1 小时前
短连接服务器压测-wrk
服务器·压力测试
陆沙1 小时前
deepseek-r1-centos-本地服务器配置方法
linux·服务器·centos
吃汤圆的抹香鲸1 小时前
Rider 安装包 绿色版 Win/Mac/Linux 适合.NET和游戏开发者使用 2025全栈开发终极指南:从零配置到企业级实战
linux·运维·windows·sql·游戏·macos·.net