Prometheus: 配置 Prometheus 伺服器以從 Node Exporter 獲取數據

本文件是從 Linux 獲取指標指南的一部分。請在此處查看完整指南:如何使用 Node Exporter 在 Prometheus 中獲取 Linux 伺服器指標

👋 歡迎來到 Stackhero 文件!

Stackhero 提供一個即用型的 Prometheus cloud 解決方案,帶來多項好處,包括:

  • 包含 Alert Manager,可發送警報至 SlackMattermostPagerDuty 等。
  • 專用電郵伺服器發送無限電郵警報
  • Blackbox 用於探測 HTTPICMPTCP 等。
  • 使用線上配置文件編輯器進行簡單配置
  • 只需點擊即可輕鬆更新
  • 專用私有 VM提供的最佳性能和強大安全性

節省時間簡化您的生活:只需5 分鐘即可嘗試 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