callback_add callback_del
This commit is contained in:
parent
e70622d18c
commit
0d05ad85f2
|
@ -181,6 +181,7 @@ func alertRulePutByService(c *gin.Context) {
|
||||||
type alertRuleFieldForm struct {
|
type alertRuleFieldForm struct {
|
||||||
Ids []int64 `json:"ids"`
|
Ids []int64 `json:"ids"`
|
||||||
Fields map[string]interface{} `json:"fields"`
|
Fields map[string]interface{} `json:"fields"`
|
||||||
|
Action string `json:"action"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// update one field: cluster note severity disabled prom_eval_interval prom_for_duration notify_channels notify_groups notify_recovered notify_repeat_step callbacks runbook_url append_tags
|
// update one field: cluster note severity disabled prom_eval_interval prom_for_duration notify_channels notify_groups notify_recovered notify_repeat_step callbacks runbook_url append_tags
|
||||||
|
@ -203,6 +204,23 @@ func alertRulePutFields(c *gin.Context) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if f.Action == "callback_add" {
|
||||||
|
// 增加一个 callback 地址
|
||||||
|
if callbacks, has := f.Fields["callbacks"]; has {
|
||||||
|
callback := callbacks.(string)
|
||||||
|
if !strings.Contains(ar.Callbacks, callback) {
|
||||||
|
f.Fields["callbacks"] = ar.Callbacks + " " + callback
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if f.Action == "callback_del" {
|
||||||
|
// 删除一个 callback 地址
|
||||||
|
if callbacks, has := f.Fields["callbacks"]; has {
|
||||||
|
f.Fields["callbacks"] = strings.ReplaceAll(ar.Callbacks, callbacks.(string), "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ginx.Dangerous(ar.UpdateFieldsMap(f.Fields))
|
ginx.Dangerous(ar.UpdateFieldsMap(f.Fields))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue