From bd82868c98f29b4394c207daf9d7588937ec94b7 Mon Sep 17 00:00:00 2001 From: zhaoxiangchun <1422928955@qq.com> Date: Mon, 19 Jul 2021 15:54:51 +0800 Subject: [PATCH] fix(monitor): fix monitor bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.支持修改默认报警策略:查询周期、连续周期和静默期 2.监控总览-图表中过滤已删除机器信息 --- pkg/monitor/alerting/conditions/query.go | 1 - pkg/monitor/models/commonalert.go | 16 ++++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/pkg/monitor/alerting/conditions/query.go b/pkg/monitor/alerting/conditions/query.go index 481c18a235..2ca5001c1d 100644 --- a/pkg/monitor/alerting/conditions/query.go +++ b/pkg/monitor/alerting/conditions/query.go @@ -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" { diff --git a/pkg/monitor/models/commonalert.go b/pkg/monitor/models/commonalert.go index c60674e750..31092653d3 100644 --- a/pkg/monitor/models/commonalert.go +++ b/pkg/monitor/models/commonalert.go @@ -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 {