告警信息
来看下告警消息体结构
结构体
type AlertMsg struct {
Receiver string
Status string
GroupLabels map[string]string
CommonLabels map[string]string
CommonAnnotations map[string]string
ExternalURL string
Alerts []Alert
}
type Alert struct {
Status string
Labels map[string]string
Annotations map[string]string
StartsAt time.Time
EndsAt time.Time
GeneratorURL string
Fingerprint string
}
API 请求查看当前告警
curl http://127.0.0.1:9093/api/v2/alerts
{
"status": "success",
"data": [
{
"labels": {
"alertname": "InstanceDown",
"instance": "localhost:9090",
"job": "prometheus"
},
"annotations": {
"description": "localhost:9090 of job prometheus has been down for more than 5 minutes.",
"summary": "Instance localhost:9090 down"
},
"startsAt": "2022-11-14T03:00:10.05Z",
"endsAt": "2022-11-14T07:11:40.05Z",
"generatorURL": "http://localhost:9090/graph?g0.expr=up+%3D%3D+1&g0.tab=1",
"status": {
"state": "active",
"silencedBy": null,
"inhibitedBy": null
},
"receivers": ["web.hook"],
"fingerprint": "b263407b9809ae48"
}
]
}