Prometheus: 配置 Prometheus 警報規則
本文件是警報指南的一部分。請在此處查看完整指南:Prometheus 警報的運作方式及其配置方法。
👋 歡迎來到 Stackhero 文件!
Stackhero 提供一個即用型的 Prometheus cloud 解決方案,帶來多項好處,包括:
- 包含
Alert Manager,可發送警報至Slack、Mattermost、PagerDuty等。- 專用電郵伺服器發送無限電郵警報。
Blackbox用於探測HTTP、ICMP、TCP等。- 使用線上配置文件編輯器進行簡單配置。
- 只需點擊即可輕鬆更新。
- 由專用私有 VM提供的最佳性能和強大安全性。
節省時間並簡化您的生活:只需5 分鐘即可嘗試 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 網站上找到更多警報規則示例。