Prometheus: 配置 Prometheus 服务器以从 Node Exporter 抓取数据

本文件是从 Linux 检索指标指南的一部分。您可以在这里查看完整指南:如何使用 Node Exporter 在 Prometheus 中检索 Linux 服务器指标

👋 欢迎来到 Stackhero 文档!

Stackhero 提供了一个完全托管的 Prometheus cloud 平台,专为高可靠性和简易性设计:

  • 内置 Alert Manager,可将告警直接发送到 SlackMattermostPagerDuty 及其他主流平台。
  • 配备专用邮件服务器,支持发送无限量邮件告警,无需额外配置。
  • 集成 Blackbox,可对 HTTPICMPTCP 及其他协议进行探测,实现全面监控。
  • 通过在线配置文件编辑器,您可以快速配置实例,无需手动管理 YAML。
  • 一键升级,Stackhero 自动为您处理升级流程,最大限度减少停机和人工干预。
  • 高性能与强大安全性内建,您的服务运行在专属的私有基础设施上。

大约 5 分钟即可完成部署。Stackhero 负责所有初始化设置,让您专注于监控本身,无需担心维护。欢迎体验 Stackhero 的 Prometheus cloud hosting,让您的监控与告警流程更加高效。

安装并保护 Node Exporter 后,配置您的 Prometheus 服务器以定期抓取指标。

在 Stackhero 上,选择您的 Prometheus 服务并转到 "Prometheus configuration" URL。然后将以下内容添加到您的 scrape_configs 部分:

scrape_configs:

  - job_name: "My servers pool"
    static_configs:
      - targets: [ "<yourLinuxServerDomain>:9100" ]
    basic_auth:
      username: "prometheus"
      password: "<password>"
    scheme: https
    tls_config:
      insecure_skip_verify: true
    # 重标记 "instance" 以移除 ":9100" 部分
    relabel_configs:
      - source_labels: [__address__]
        target_label: instance
        regex: '([^:]+)(:[0-9]+)?'
        replacement: '${1}'

保存文件并检查 Prometheus 日志以确认它已成功重新加载(您可以通过选择您的 Prometheus 服务并点击 "Logs" 选项卡从 Stackhero 仪表板查看日志)。

最后,通过访问 Stackhero 仪表板上的 Prometheus UI 并导航到 Status > Targets,验证 Prometheus 是否正在抓取指标。您的 Linux 服务器应在目标列表中显示为 UP。

目标 "myLinuxServer" 是 UP目标 "myLinuxServer" 是 UP