Prometheus: 配置 Prometheus 警報規則

本文件是警報指南的一部分。請在此處查看完整指南:Prometheus 警報的運作方式及其配置方法

👋 歡迎來到 Stackhero 文件中心!

Stackhero 提供全代管的 Prometheus cloud 平台,專為高可靠性與簡易操作而設計:

  • 內建 Alert Manager,可直接將警報發送到 SlackMattermostPagerDuty 及其他主流平台。
  • 專屬電子郵件伺服器,讓您無需額外設定即可發送無限量電子郵件警報
  • 內含 Blackbox,可針對 HTTPICMPTCP 等多種協定進行全面監控探測。
  • 可透過線上設定檔編輯器快速設定您的實例,無需手動管理 YAML。
  • 一鍵升級,Stackhero 會自動處理更新流程,最大程度減少停機與人工干預。
  • 專屬私有基礎架構,內建高效能與強化安全性。

約 5 分鐘即可完成部署。Stackhero 幫您搞定所有安裝設定,讓您專注於監控本身,而非維護作業。立即體驗 Prometheus cloud hosting on Stackhero,讓您的監控與警報流程更有效率。

您可以通過編輯 rules-alert.yml 文件來調整 Prometheus 警報規則。為此,請訪問您的 Stackhero 儀表板,選擇您的 Prometheus 服務,然後點擊 "Prometheus 警報規則配置"。

我們已經在您的 Stackhero for Prometheus 實例中添加了一些默認警報規則,因此通常不需要修改 rules-alert.yml 文件,除非需要自定義。

以下是一個當磁碟使用量超過 90% 時觸發的警報示例:

- alert: "HostOutOfDiskSpace"
  expr: (node_filesystem_avail_bytes * 100) / node_filesystem_size_bytes < 10 and ON (instance, device, mountpoint) node_filesystem_readonly == 0
  for: 2m
  labels:
    severity: "warning"
  annotations:
    summary: "Host out of disk space (instance {{ $labels.instance }})"
    description: "Disk is almost full (< 10% left)"
    value: "{{ $value }}"

這是另一個預測未來 24 小時內磁碟空間飽和的示例:

- alert: "HostDiskWillFillIn24Hours"
  expr: (node_filesystem_avail_bytes * 100) / node_filesystem_size_bytes < 10 and ON (instance, device, mountpoint) predict_linear(node_filesystem_avail_bytes{fstype!~"tmpfs"}[1h], 24 * 3600) < 0 and ON (instance, device, mountpoint) node_filesystem_readonly == 0
  for: 2m
  labels:
    severity: "warning"
  annotations:
    summary: "Host disk will fill in 24 hours (instance {{ $labels.instance }})"
    description: "Filesystem is predicted to run out of space within the next 24 hours at the current write rate"
    value: "{{ $value }}"

您可以在 Awesome Prometheus Alerts 網站上找到更多警報規則示例。