# alertmanager.yml
global:
resolve_timeout: 5m
route:
group_by: ['alertname']
group_wait: 30s
group_interval: 5m
repeat_interval: 3h
receiver: 'sms'
receivers:
- name: 'sms'
webhook_configs:
- url: 'http://xxx'
send_resolved: true
import requests
import json
def send_sms(mobile, content):
url = 'http://106.ihuyi.com/webservice/sms.php?method=Submit'
payload = {
'account':'xxxxxxxx',
'password':'xxxxxxxxxxxx',
'mobile':mobile,
'content':content,
'format':'json',
}
headers = {
"Content-type": "application/x-www-form-urlencoded",
"Accept": "text/plain"
}
response = requests.post(url, headers=headers, data=data)
res = json.loads(response.content.decode())
if res['code'] == 2:
print('短信發(fā)送成功')
else:
print('短信發(fā)送失敗')
# prometheus.yml
rule_files:
- 'alert.rules.yml'
alerting:
alertmanagers:
- static_configs:
- targets: ['alertmanager:9093']
# alert.rules.yml
groups:
- name: example
rules:
- alert: HighErrorRate
expr: job:request_error_rate:rate5m > 0.5
for: 5m
labels:
severity: warning
annotations:
summary: 'High error rate detected'
description: 'The error rate is above 0.5'
# prometheus.yml
alerting:
alertmanagers:
- static_configs:
- targets: ['alertmanager:9093']
$ alertmanager
驗證碼已發(fā)送到您的手機,請查收!
輸入驗證碼后,點擊“開通體驗賬戶”按鈕可立即開通體驗賬戶。