Merge pull request #11757 from zhaoxiangchun/automated-cherry-pick-of-#11672-upstream-release-3.7

Automated cherry pick of #11672: fix(monitor): fix monitor bug
This commit is contained in:
Zexi Li
2021-07-31 11:45:10 +08:00
committed by GitHub
2 changed files with 6 additions and 11 deletions
-1
View File
@@ -520,7 +520,6 @@ func (c *QueryCondition) setResType() {
}
if len(resType) != 0 && c.Query.Model.GroupBy[0].Params[0] != monitor.
MEASUREMENT_TAG_ID[resType] {
resType = ""
for _, groupBy := range c.Query.Model.GroupBy {
tag := groupBy.Params[0]
if tag == "tenant_id" {
+6 -10
View File
@@ -865,6 +865,11 @@ func (alert *SCommonAlert) ValidateUpdateData(
if period != "" {
frep, _ := time.ParseDuration(period)
freqSpec := int64(frep / time.Second)
dur, _ := data.Int("alert_duration")
if dur > 1 {
alertFor := freqSpec * dur
data.Set("for", jsonutils.NewInt(alertFor))
}
data.Set("frequency", jsonutils.NewInt(freqSpec))
}
}
@@ -873,16 +878,7 @@ func (alert *SCommonAlert) ValidateUpdateData(
return data, httperrors.NewInputParameterError("Invalid silent_period format: %s", silentPeriod)
}
}
//if recipients, _ := data.GetArray("recipients"); len(recipients) > 0 {
// channelStr, _ := data.GetString("channel")
// channel, _ := data.GetArray("channel")
// if !strings.Contains(channelStr, monitor.DEFAULT_SEND_NOTIFY_CHANNEL) {
// channels := jsonutils.NewArray()
// channels.Add(channel...)
// channels.Add(jsonutils.NewString(monitor.DEFAULT_SEND_NOTIFY_CHANNEL))
// data.Set("channel", channels)
// }
//}
tmp := jsonutils.NewArray()
if metric_query, _ := data.GetArray("metric_query"); len(metric_query) > 0 {
for i := range metric_query {