diff options
| author | shizhendong <[email protected]> | 2020-06-04 19:19:37 +0800 |
|---|---|---|
| committer | shizhendong <[email protected]> | 2020-06-04 19:19:37 +0800 |
| commit | f9741cc11f14c3a415cc8d0bf9c9a8b8e82500e6 (patch) | |
| tree | 7c1436c3ac34081cd64a86b9893a30cf606c8e39 | |
| parent | 438e3dfa768f8273c7518b4ebc9122b6a07d2d30 (diff) | |
NEZ-308 fix: 修改rule expr表达式格式
| -rw-r--r-- | src/main/java/com/nis/entity/AlertRule.java | 17 | ||||
| -rw-r--r-- | src/main/java/com/nis/job/ConfagentJob.java | 2 | ||||
| -rw-r--r-- | src/main/resources/mapper/AlertRuleDao.xml | 5 |
3 files changed, 21 insertions, 3 deletions
diff --git a/src/main/java/com/nis/entity/AlertRule.java b/src/main/java/com/nis/entity/AlertRule.java index c9147aa..2b57189 100644 --- a/src/main/java/com/nis/entity/AlertRule.java +++ b/src/main/java/com/nis/entity/AlertRule.java @@ -1,7 +1,10 @@ package com.nis.entity;
+import lombok.Data;
+
import java.io.Serializable;
+@Data
public class AlertRule implements Serializable{
private Integer id;
@@ -14,6 +17,20 @@ public class AlertRule implements Serializable{ */
private String expr;
/**
+ * 比较符号
+ */
+ private String operator;
+
+ /**
+ * 阈值
+ */
+ private Long threshold;
+
+ /**
+ * 单位
+ */
+ private Integer unit;
+ /**
* 持续时间,单位s
*/
private Integer last;
diff --git a/src/main/java/com/nis/job/ConfagentJob.java b/src/main/java/com/nis/job/ConfagentJob.java index b20033d..3244ac0 100644 --- a/src/main/java/com/nis/job/ConfagentJob.java +++ b/src/main/java/com/nis/job/ConfagentJob.java @@ -507,7 +507,7 @@ public class ConfagentJob extends QuartzJobBean { annotations.put("description", alertRule.getDescription()); Map rule = new HashMap(); rule.put("alert", alertRule.getId()); - rule.put("expr", alertRule.getExpr()); + rule.put("expr", "(" + alertRule.getExpr() + ")" + alertRule.getOperator() + alertRule.getThreshold()); rule.put("for", alertRule.getLast() + "s"); rule.put("labels", labels); rule.put("annotations", annotations); diff --git a/src/main/resources/mapper/AlertRuleDao.xml b/src/main/resources/mapper/AlertRuleDao.xml index 569e6df..beed561 100644 --- a/src/main/resources/mapper/AlertRuleDao.xml +++ b/src/main/resources/mapper/AlertRuleDao.xml @@ -5,13 +5,14 @@ <result property="id" column="id"/> <result property="alertName" column="alert_name"/> <result property="expr" column="expr"/> + <result property="operator" column="operator"/> + <result property="threshold" column="threshold"/> + <result property="unit" column="unit"/> <result property="last" column="last"/> <result property="severity" column="severity"/> <result property="summary" column="summary"/> <result property="description" column="description"/> <result property="receiver" column="receiver"/> - <result property="type" column="type"/> - <result property="linkId" column="link_id"/> <result property="buildIn" column="build_in"/> </resultMap> |
