alertmanager发出的报警webhook格式记录.md
alertmanager配置文件
global:
resolve_timeout: 5m
route:
group_by: ['instance']
group_wait: 10s
group_interval: 20s
repeat_interval: 20s
#repeat_interval: 1h
receiver: 'webhook'
receivers:
- name: 'webhook'
webhook_configs:
- url: 'http://192.168.111.1:5000/send'
通过webhook发出去的是json格式的数据包,
json内容如下
{
"receiver": "webhook",
"status": "firing",
"alerts": [
{
"status": "firing",
"labels": {
"alertname": "NodeIOWaitOvercommit",
"instance": "192.168.0.4:9100",
"prometheus": "monitoring/k8s",
"resource_type": "node",
"severity": "critical"
},
"annotations": {
"description": "High Node CPU IO Wait",
"message": "",
"summary": ""
},
"startsAt": "2018-11-22T01:10:34.637265174Z",
"endsAt": "2018-11-22T06:28:34.637265174Z",
"generatorURL": "http://0.0.0.0:9090/graph?g0.expr=instance:node_cpu_iowait:sum+>+1&g0.tab=1"
},
{"status": "resolved",
"labels": {
"alertname": "NodeIOWaitOvercommit",
"instance": "192.168.0.3:9100",
"prometheus": "monitoring/k8s",
"resource_type": "node",
"severity": "critical"
},
"annotations": {
"description": "High Node CPU IO Wait",
"message": "",
"summary": ""
},
"startsAt": "2018-11-22T01:10:34.637265174Z",
"endsAt": "2018-11-22T06:27:04.637265174Z",
"generatorURL": "http://0.0.0.0:9090/graph?g0.expr=instance:node_cpu_iowait:sum+>+1&g0.tab=1"
},
{
"status": "firing",
"labels": {
"alertname": "NodeIOWaitOvercommit",
"instance": "192.168.0.2:9100",
"prometheus": "monitoring/k8s",
"resource_type": "node",
"severity": "critical"
},
"annotations": {
"description": "High Node CPU IO Wait",
"message": "",
"summary": ""
},
"startsAt": "2018-11-22T01:10:34.637265174Z",
"endsAt": "2018-11-22T06:28:34.637265174Z",
"generatorURL": "http://0.0.0.0:9090/graph?g0.expr=instance:node_cpu_iowait:sum+>+1&g0.tab=1"
}],
"groupLabels": {
"alertname": "NodeIOWaitOvercommit"
},
"commonLabels": {
"alertname": "NodeIOWaitOvercommit",
"prometheus": "monitoring/k8s",
"resource_type": "node",
"severity": "critical"
},
"commonAnnotations": {
"description": "High Node CPU IO Wait"
},
"externalURL": "http://127.0.0.1:9093",
"version": "4",
"groupKey": "{}/{resource_type=~\"^(?:node)$\"}:{alertname=\"NodeIOWaitOvercommit\"}"
}
alerts是一个list列表,里面可以存放firing状态的报警和resolved状态的报警。而最外层的status状态其实没什么意义,实际对接时,直接获取alerts里面的内容。