Prometheus: 配置 Prometheus 警報規則
此文件屬於警報指南的一部分。請在此處查看完整指南:Prometheus 警報的運作方式及其配置方法。
👋 歡迎瀏覽 Stackhero 文件!
Stackhero 提供一個全託管的 Prometheus cloud 平台,專為高可靠性和簡易操作而設:
- 內建
Alert Manager,讓您可以直接將警報發送到Slack、Mattermost、PagerDuty及其他主流平台。- 專屬電郵伺服器,讓您無需額外設定即可發送無限量電郵警報。
- 包含
Blackbox,可針對HTTP、ICMP、TCP及其他協議進行全面監控探測。- 使用線上設定檔編輯器,快速配置您的實例,無需手動處理 YAML。
- 一鍵升級,Stackhero 會為您處理整個升級流程,減少停機時間及人手干預。
- 高效能及強大安全性,皆因您擁有專屬的私有基礎設施。
大約 5 分鐘即可完成部署。Stackhero 會處理所有設定,讓您專注於監控,而非維護。立即試用 Stackhero 的 Prometheus cloud hosting,簡化您的監控及警報流程。
您可以通過編輯 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 網站上找到更多警報規則示例。