一、编写sh脚本发送告警信息到alertmanager
alertmanager的接口文件定义可以参考:
https://github.com/prometheus/alertmanager/blob/main/api/v2/openapi.yaml
我们只需要将告警的信息发送到/api/v2/alerts 中即可,使用POST方法发送
#!/usr/bin/env bash
alerts1='[
{
"labels": {
"alertname": "DiskRunningFull",
"dev": "sda1",
"instance": "example1"
},
"annotations": {
"info": "The disk sda1 is running full",
"summary": "please check the instance example1"
}
},
{
"labels": {
"alertname": "DiskRunningFull",
"dev": "sda2",
"instance": "example1"
},
"annotations": {
"info": "The disk sda2 is running full",
"summary": "please check the instance example1",
"runbook": "the following link http://test-url should be clickable"
}
},
{
"labels": {
"alertname": "DiskRunningFull",
"dev": "sda1",
"instance": "example2"
},
"annotations": {
"info":