From 5cbbdfa42763b3d65e0586626c346cca4380d547 Mon Sep 17 00:00:00 2001 From: like Date: Wed, 5 Jul 2023 15:36:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=A2=84=E8=AD=A6=E8=A7=84=E5=88=99?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E8=AF=A6=E6=83=85=E5=AD=97=E6=AE=B5=E7=BC=BA?= =?UTF-8?q?=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bean/vo/response/alert_rules.go | 1 + src/service/alert_rules.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bean/vo/response/alert_rules.go b/src/bean/vo/response/alert_rules.go index c35a6a3..a64bcc1 100644 --- a/src/bean/vo/response/alert_rules.go +++ b/src/bean/vo/response/alert_rules.go @@ -4,6 +4,7 @@ import "gitlab.wodcloud.com/smart-operation/so-operation-api/src/bean/entity" type AlertRulesItem struct { entity.AlertRules `xorm:"extends"` + Expr string `json:"expr" form:"expr"` // 指标表达式(PromQL语句) AlertRuleType string `json:"alert_rule_type" xorm:"alert_rule_type"` // 预警规则类型 关联字典表 ClassParentName string `json:"class_parent_name" xorm:"class_parent_name"` ClassName string `json:"class_name" xorm:"class_name"` diff --git a/src/service/alert_rules.go b/src/service/alert_rules.go index 9ae340a..36495bd 100644 --- a/src/service/alert_rules.go +++ b/src/service/alert_rules.go @@ -213,7 +213,7 @@ func (a *AlertRulesSvc) List(req request.ListAlertRules) (resp response.AlertRul } session := db.NewSession() defer session.Close() - session.Table(new(entity.AlertRules)).Alias("r").Select("r.*,acp.class_name class_parent_name,ac.class_name,mc.metric_name metric_config_name,mc.alert_rule_type") + session.Table(new(entity.AlertRules)).Alias("r").Select("r.*,acp.class_name class_parent_name,ac.class_name,mc.expr,mc.metric_name metric_config_name,mc.alert_rule_type") session.Join("LEFT", "metric_config mc", "mc.id = r.metric_config_id") session.Join("LEFT", "alert_class ac", "ac.class_id = r.class_id") session.Join("LEFT", "alert_class acp", "acp.class_id = ac.parent_id") -- 2.26.0