Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions controllers/prometheusalert.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ type PrometheusAlertMsg struct {

func (c *PrometheusAlertController) PrometheusAlert() {
logsign := "[" + LogsSign() + "]"
var message string
var p_json interface{}
//针对prometheus的消息特殊处理
p_alertmanager_json := make(map[string]interface{})
Expand Down Expand Up @@ -107,7 +108,11 @@ func (c *PrometheusAlertController) PrometheusAlert() {
AliyunAlertJson.Timestamp = c.Input().Get("timestamp")
p_json = AliyunAlertJson
} else {
json.Unmarshal(c.Ctx.Input.RequestBody, &p_json)
err := json.Unmarshal(c.Ctx.Input.RequestBody, &p_json)
if err != nil {
message = "请求body不是合法json."
logs.Error(logsign, message)
}
//针对prometheus的消息特殊处理
json.Unmarshal(c.Ctx.Input.RequestBody, &p_alertmanager_json)
}
Expand Down Expand Up @@ -161,7 +166,6 @@ func (c *PrometheusAlertController) PrometheusAlert() {
}
}

var message string
if pMsg.Type != "" && PrometheusAlertTpl != nil {
//判断是否是来自 Prometheus的告警
if pMsg.Split != "false" && PrometheusAlertTpl.Tpluse == "Prometheus" {
Expand Down