diff --git a/skywalking-webui/src/main/java/com/ai/cloud/controller/AlarmRuleCtl.java b/skywalking-webui/src/main/java/com/ai/cloud/controller/AlarmRuleCtl.java index 52beb277f..f363f3f81 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/controller/AlarmRuleCtl.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/controller/AlarmRuleCtl.java @@ -1,5 +1,8 @@ package com.ai.cloud.controller; +import java.util.ArrayList; +import java.util.List; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; @@ -20,6 +23,7 @@ import com.ai.cloud.util.common.StringUtil; import com.ai.cloud.vo.mvo.AlarmRuleMVO; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.sun.activation.registries.MailcapTokenizer; @Controller public class AlarmRuleCtl { @@ -38,7 +42,8 @@ public class AlarmRuleCtl { */ @RequestMapping(value = "/alarmRule/default", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") @ResponseBody - public String queryUserDefaultAlarmRule(HttpServletRequest request, ModelMap root, @RequestBody String json) throws Exception { + public String queryUserDefaultAlarmRule(HttpServletRequest request, ModelMap root, @RequestBody String json) + throws Exception { HttpSession session = request.getSession(); String uid = (String) session.getAttribute("uid"); @@ -55,7 +60,6 @@ public class AlarmRuleCtl { ruleMVO = alarmRuleSer.queryUserDefaultAlarmRule(ruleMVO); - if (ruleMVO != null && !StringUtil.isBlank(ruleMVO.getRuleId())) { reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_OK); reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "查询到默认数据"); @@ -64,11 +68,10 @@ public class AlarmRuleCtl { reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未查询到默认数据"); } - return reJson.toJSONString(); } - + /*** * 查询用户默认规则 * @@ -78,7 +81,8 @@ public class AlarmRuleCtl { */ @RequestMapping(value = "/alarmRule/{appId}", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") @ResponseBody - public String queryAppAlarmRule(HttpServletRequest request, ModelMap root, @PathVariable("appId") String appId) throws Exception { + public String queryAppAlarmRule(HttpServletRequest request, ModelMap root, @PathVariable("appId") String appId) + throws Exception { HttpSession session = request.getSession(); String uid = (String) session.getAttribute("uid"); @@ -104,10 +108,10 @@ public class AlarmRuleCtl { reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未查询到默认数据"); } - + return reJson.toJSONString(); } - + /*** * 创建用户默认规则 * @@ -117,7 +121,8 @@ public class AlarmRuleCtl { */ @RequestMapping(value = "/alarmRule/create", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") @ResponseBody - public String createAppAlarmRule(HttpServletRequest request, ModelMap root, @RequestBody String jsonStr) throws Exception { + public String createAppAlarmRule(HttpServletRequest request, ModelMap root, @RequestBody String jsonStr) + throws Exception { HttpSession session = request.getSession(); String uid = (String) session.getAttribute("uid"); @@ -128,53 +133,75 @@ public class AlarmRuleCtl { reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "用户会话超时"); return reJson.toJSONString(); } - + JSONObject json = JSON.parseObject(jsonStr); - if(!json.containsKey("isGlobal")){ + if (!json.containsKey("isGlobal")) { reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到isGlobal参数信息"); + return reJson.toJSONString(); } String isGlobal = json.getString("isGlobal"); - if(!json.containsKey("period")){ + if (!json.containsKey("period")) { reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到告警间隔参数信息"); + return reJson.toJSONString(); } String period = json.getString("period"); - if(!json.containsKey("todoType")){ + if (!json.containsKey("todoType")) { reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到操作类型参数信息"); + return reJson.toJSONString(); } String todoType = json.getString("todoType"); - if(!json.containsKey("todoContent")){ + + String mailTo = null; + String mailCc = null; + if (Constants.TODO_TYPE_0.equals(todoType)) { + if (!json.containsKey("mailTo")) { + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到邮件发送人信息"); + return reJson.toJSONString(); + } + mailTo = json.getString("mailTo").replace("\n", ""); + if (json.containsKey("mailCc")) { + mailCc = json.getString("mailCc").replace("\n", ""); + } + if (!json.containsKey("mailTemp")) { + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到邮件模板信息"); + return reJson.toJSONString(); + } + } else if (Constants.TODO_TYPE_1.equals(todoType)) { + if (!json.containsKey("urlCall")) { + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到回调接口信息"); + return reJson.toJSONString(); + } + } else { reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); - if("1".equals(todoType)){ - reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到回调地址参数信息"); - } - else{ - reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到邮件模板参数信息"); - } + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未定义告警操作类型"); + return reJson.toJSONString(); } - String todoContent = json.getString("todoContent"); AlarmRuleMVO srchRuleMVO = new AlarmRuleMVO(); srchRuleMVO.setUid(uid); srchRuleMVO.setSts(Constants.STR_VAL_A); srchRuleMVO.setIsGlobal(isGlobal); - - //判断是否为全局规则 - if(Constants.IS_GLOBAL_FALG_1.equals(isGlobal)){ + + // 判断是否为全局规则 + if (Constants.IS_GLOBAL_FALG_1.equals(isGlobal)) { srchRuleMVO = alarmRuleSer.queryUserDefaultAlarmRule(srchRuleMVO); if (srchRuleMVO != null && !StringUtil.isBlank(srchRuleMVO.getRuleId())) { reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "默认告警规则已经存在"); return reJson.toJSONString(); } - }else{ - if(!json.containsKey("appId")){ + } else { + if (!json.containsKey("appId")) { reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到appId参数信息"); return reJson.toJSONString(); - }else{ + } else { srchRuleMVO.setAppId(json.getString("appId")); srchRuleMVO = alarmRuleSer.queryAppAlarmRule(srchRuleMVO); if (srchRuleMVO != null && !StringUtil.isBlank(srchRuleMVO.getRuleId())) { @@ -184,31 +211,51 @@ public class AlarmRuleCtl { } } } - + AlarmRuleMVO ruleMVO = new AlarmRuleMVO(); ruleMVO.setUid(uid); ruleMVO.setAppId(json.getString("appId")); ruleMVO.setSts(Constants.STR_VAL_A); ruleMVO.setIsGlobal(isGlobal); ruleMVO.setTodoType(todoType); - ruleMVO.setTodoContent(todoContent); JSONObject confArgs = new JSONObject(); confArgs.put("period", period); + if (Constants.TODO_TYPE_0.equals(todoType)) { + // 设置邮件相关的信息 + JSONObject mailInfo = new JSONObject(); + + String[] mailToList = mailTo.split(Constants.MAIL_SPLIT_CHAR); + + if (!StringUtil.isBlank(mailCc)) { + String[] mailCcList = mailCc.split(Constants.MAIL_SPLIT_CHAR); + mailInfo.put("mailCc", mailCcList); + } + + mailInfo.put("mailTo", mailToList); + mailInfo.put("mailTemp", json.getString("mailTemp")); + confArgs.put("mailInfo", mailInfo); + } else if (Constants.TODO_TYPE_1.equals(todoType)) { + // 设置接口相关的信息 + JSONObject urlInfo = new JSONObject(); + urlInfo.put("urlCall", json.getString("urlCall")); + confArgs.put("urlInfo", urlInfo); + } + ruleMVO.setConfigArgs(confArgs.toJSONString()); - - try{ + + try { ruleMVO = alarmRuleSer.createAlarmRule(ruleMVO); reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_OK); reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "操作成功"); - - }catch(Exception e){ + + } catch (Exception e) { reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "创建告警规则失败"); e.printStackTrace(); } return reJson.toJSONString(); } - + /*** * 创建用户默认规则 * @@ -218,7 +265,8 @@ public class AlarmRuleCtl { */ @RequestMapping(value = "/alarmRule/modify", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") @ResponseBody - public String modifyAppAlarmRule(HttpServletRequest request, ModelMap root, @RequestBody String jsonStr) throws Exception { + public String modifyAppAlarmRule(HttpServletRequest request, ModelMap root, @RequestBody String jsonStr) + throws Exception { HttpSession session = request.getSession(); String uid = (String) session.getAttribute("uid"); @@ -229,53 +277,90 @@ public class AlarmRuleCtl { reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "用户会话超时"); return reJson.toJSONString(); } - + JSONObject json = JSON.parseObject(jsonStr); - if(!json.containsKey("isGlobal")){ + if (!json.containsKey("isGlobal")) { reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到isGlobal参数信息"); } String isGlobal = json.getString("isGlobal"); - if(!json.containsKey("period")){ + if (!json.containsKey("period")) { reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到告警间隔参数信息"); } String period = json.getString("period"); - if(!json.containsKey("todoType")){ + if (!json.containsKey("todoType")) { reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到操作类型参数信息"); } String ruleId = json.getString("ruleId"); - if(!json.containsKey("ruleId")){ + if (!json.containsKey("ruleId")) { reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到告警规则参数信息"); } String todoType = json.getString("todoType"); - if(!json.containsKey("todoContent")){ + String mailTo = null; + String mailCc = null; + if (Constants.TODO_TYPE_0.equals(todoType)) { + if (!json.containsKey("mailTo")) { + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到邮件发送人信息"); + return reJson.toJSONString(); + } + mailTo = json.getString("mailTo").replace("\n", ""); + if (json.containsKey("mailCc")) { + mailCc = json.getString("mailCc").replace("\n", ""); + } + if (!json.containsKey("mailTemp")) { + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到邮件模板信息"); + return reJson.toJSONString(); + } + } else if (Constants.TODO_TYPE_1.equals(todoType)) { + if (!json.containsKey("urlCall")) { + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到回调接口信息"); + return reJson.toJSONString(); + } + } else { reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); - if("1".equals(todoType)){ - reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到回调地址参数信息"); - } - else{ - reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到邮件模板参数信息"); - } + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未定义告警操作类型"); + return reJson.toJSONString(); } - String todoContent = json.getString("todoContent"); AlarmRuleMVO ruleMVO = new AlarmRuleMVO(); ruleMVO.setRuleId(ruleId); ruleMVO.setTodoType(todoType); - ruleMVO.setTodoContent(todoContent); JSONObject confArgs = new JSONObject(); confArgs.put("period", period); + if (Constants.TODO_TYPE_0.equals(todoType)) { + // 设置邮件相关的信息 + JSONObject mailInfo = new JSONObject(); + + String[] mailToList = mailTo.split(Constants.MAIL_SPLIT_CHAR); + + if (!StringUtil.isBlank(mailCc)) { + String[] mailCcList = mailCc.split(Constants.MAIL_SPLIT_CHAR); + mailInfo.put("mailCc", mailCcList); + } + + mailInfo.put("mailTo", mailToList); + mailInfo.put("mailTemp", json.getString("mailTemp")); + confArgs.put("mailInfo", mailInfo); + } else if (Constants.TODO_TYPE_1.equals(todoType)) { + // 设置接口相关的信息 + JSONObject urlInfo = new JSONObject(); + urlInfo.put("urlCall", json.getString("urlCall")); + confArgs.put("urlInfo", urlInfo); + } ruleMVO.setConfigArgs(confArgs.toJSONString()); - - try{ + + try { ruleMVO = alarmRuleSer.modifyAlarmRule(ruleMVO); reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_OK); reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "操作成功"); - - }catch(Exception e){ + + } catch (Exception e) { reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "创建告警规则失败"); e.printStackTrace(); diff --git a/skywalking-webui/src/main/java/com/ai/cloud/dao/impl/AlarmRuleMDAO.java b/skywalking-webui/src/main/java/com/ai/cloud/dao/impl/AlarmRuleMDAO.java index ffbf572a7..1ad5c8aa6 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/dao/impl/AlarmRuleMDAO.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/dao/impl/AlarmRuleMDAO.java @@ -30,7 +30,7 @@ public class AlarmRuleMDAO implements IAlarmRuleMDAO { @Override public AlarmRuleMVO queryUserDefaultAlarmRule(AlarmRuleMVO rule) { final AlarmRuleMVO ruleMVO = new AlarmRuleMVO(); - String sql = "select rule_id,app_id,uid,config_args,is_global,todo_type,todo_content,create_time,sts,modify_time from alarm_rule a where a.uid = ? and a.is_global = '1' and a.sts='A'"; + String sql = "select rule_id,app_id,uid,config_args,is_global,todo_type,create_time,sts,modify_time from alarm_rule a where a.uid = ? and a.is_global = '1' and a.sts='A'"; final Object[] params = new Object[] { rule.getUid() }; jdbcTemplate.query(sql, params, new RowCallbackHandler() { @Override @@ -41,7 +41,6 @@ public class AlarmRuleMDAO implements IAlarmRuleMDAO { ruleMVO.setConfigArgs(rs.getString("config_args")); ruleMVO.setIsGlobal(rs.getString("is_global")); ruleMVO.setTodoType(rs.getString("todo_type")); - ruleMVO.setTodoContent(rs.getString("todo_content")); ruleMVO.setCreateTime(rs.getTimestamp("create_time")); ruleMVO.setSts(rs.getString("sts")); ruleMVO.setModifyTime(rs.getTimestamp("modify_time")); @@ -54,7 +53,7 @@ public class AlarmRuleMDAO implements IAlarmRuleMDAO { @Override public AlarmRuleMVO queryAppAlarmRule(AlarmRuleMVO rule) { final AlarmRuleMVO ruleMVO = new AlarmRuleMVO(); - String sql = "select rule_id,app_id,uid,config_args,is_global,todo_type,todo_content,create_time,sts,modify_time from alarm_rule a where a.uid = ? and app_id = ? and a.is_global = '0' and a.sts='A'"; + String sql = "select rule_id,app_id,uid,config_args,is_global,todo_type,create_time,sts,modify_time from alarm_rule a where a.uid = ? and app_id = ? and a.is_global = '0' and a.sts='A'"; final Object[] params = new Object[] { rule.getUid(), rule.getAppId() }; jdbcTemplate.query(sql, params, new RowCallbackHandler() { @Override @@ -65,7 +64,6 @@ public class AlarmRuleMDAO implements IAlarmRuleMDAO { ruleMVO.setConfigArgs(rs.getString("config_args")); ruleMVO.setIsGlobal(rs.getString("is_global")); ruleMVO.setTodoType(rs.getString("todo_type")); - ruleMVO.setTodoContent(rs.getString("todo_content")); ruleMVO.setCreateTime(rs.getTimestamp("create_time")); ruleMVO.setSts(rs.getString("sts")); ruleMVO.setModifyTime(rs.getTimestamp("modify_time")); @@ -77,7 +75,7 @@ public class AlarmRuleMDAO implements IAlarmRuleMDAO { @Override public AlarmRuleMVO createAlarmRule(final AlarmRuleMVO ruleMVO) { - final String sql = "insert into alarm_rule (app_id,uid,config_args,is_global,todo_type,todo_content,create_time,sts,modify_time) values (?,?,?,?,?,?,sysdate(),?,sysdate())"; + final String sql = "insert into alarm_rule (app_id,uid,config_args,is_global,todo_type,create_time,sts,modify_time) values (?,?,?,?,?,sysdate(),?,sysdate())"; KeyHolder keyHolder = new GeneratedKeyHolder(); int count = jdbcTemplate.update(new PreparedStatementCreator() { @@ -89,7 +87,6 @@ public class AlarmRuleMDAO implements IAlarmRuleMDAO { pstmt.setString(++i, ruleMVO.getConfigArgs()); pstmt.setString(++i, ruleMVO.getIsGlobal()); pstmt.setString(++i, ruleMVO.getTodoType()); - pstmt.setString(++i, ruleMVO.getTodoContent()); pstmt.setString(++i, ruleMVO.getSts()); return pstmt; } @@ -102,7 +99,7 @@ public class AlarmRuleMDAO implements IAlarmRuleMDAO { @Override public AlarmRuleMVO modifyAlarmRule(final AlarmRuleMVO ruleMVO) { - final String sql = "update alarm_rule set config_args = ?,todo_type = ?,todo_content = ? where rule_id = ?"; + final String sql = "update alarm_rule set config_args = ?,todo_type = ? where rule_id = ?"; int count = jdbcTemplate.update(new PreparedStatementCreator() { public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { @@ -110,7 +107,6 @@ public class AlarmRuleMDAO implements IAlarmRuleMDAO { int i = 0; pstmt.setString(++i, ruleMVO.getConfigArgs()); pstmt.setString(++i, ruleMVO.getTodoType()); - pstmt.setString(++i, ruleMVO.getTodoContent()); pstmt.setString(++i, ruleMVO.getRuleId()); return pstmt; } diff --git a/skywalking-webui/src/main/java/com/ai/cloud/util/Constants.java b/skywalking-webui/src/main/java/com/ai/cloud/util/Constants.java index c90e02aa4..cc18aba17 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/util/Constants.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/util/Constants.java @@ -73,5 +73,10 @@ public class Constants { public static final String IS_GLOBAL_FALG_0 = "0"; public static final String IS_GLOBAL_FALG_1 = "1"; + + public static final String TODO_TYPE_0 = "0"; + public static final String TODO_TYPE_1 = "1"; + + public static final String MAIL_SPLIT_CHAR = ","; } diff --git a/skywalking-webui/src/main/java/com/ai/cloud/vo/svo/AlarmRuleSVO.java b/skywalking-webui/src/main/java/com/ai/cloud/vo/svo/AlarmRuleSVO.java index 64d3ba350..530be2073 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/vo/svo/AlarmRuleSVO.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/vo/svo/AlarmRuleSVO.java @@ -10,13 +10,11 @@ public class AlarmRuleSVO { private String uid; - private String configArgs; - private String isGlobal; private String todoType; - private String todoContent; + private String configArgs; private Timestamp createTime; @@ -88,14 +86,6 @@ public class AlarmRuleSVO { this.sts = sts; } - public String getTodoContent() { - return todoContent; - } - - public void setTodoContent(String todoContent) { - this.todoContent = todoContent; - } - public Timestamp getModifyTime() { return modifyTime; } @@ -106,14 +96,9 @@ public class AlarmRuleSVO { @Override public String toString() { - return "AlarmRuleSVO [ruleId=" + ruleId + ", appId=" + appId + ", uid=" + uid + ", configArgs=" + configArgs - + ", isGlobal=" + isGlobal + ", todoType=" + todoType + ", todoContent=" + todoContent + ", createTime=" - + createTime + ", sts=" + sts + ", modifyTime=" + modifyTime + ", getRuleId()=" + getRuleId() - + ", getAppId()=" + getAppId() + ", getUid()=" + getUid() + ", getConfigArgs()=" + getConfigArgs() - + ", getIsGlobal()=" + getIsGlobal() + ", getTodoType()=" + getTodoType() + ", getCreateTime()=" - + getCreateTime() + ", getSts()=" + getSts() + ", getTodoContent()=" + getTodoContent() - + ", getModifyTime()=" + getModifyTime() + ", getClass()=" + getClass() + ", hashCode()=" + hashCode() - + ", toString()=" + super.toString() + "]"; + return "AlarmRuleSVO [ruleId=" + ruleId + ", appId=" + appId + ", uid=" + uid + ", isGlobal=" + isGlobal + + ", todoType=" + todoType + ", configArgs=" + configArgs + ", createTime=" + createTime + ", sts=" + + sts + ", modifyTime=" + modifyTime + "]"; } } diff --git a/skywalking-webui/src/main/webapp/ftl/applist.ftl b/skywalking-webui/src/main/webapp/ftl/applist.ftl index ed67c48b0..4486e3c17 100644 --- a/skywalking-webui/src/main/webapp/ftl/applist.ftl +++ b/skywalking-webui/src/main/webapp/ftl/applist.ftl @@ -55,16 +55,30 @@ -
- -
- -
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
@@ -208,13 +222,15 @@ $("#appName").text("所有应用"); if(result == 'OK'){ var obj = jQuery.parseJSON(data.data); - var periodJson = jQuery.parseJSON(obj.configArgs); - $("#period").val(periodJson.period); + var confArg = jQuery.parseJSON(obj.configArgs); + $("#period").val(confArg.period); $("#todoType").val(obj.todoType).change(); if(obj.todoType == 1){ - $("#callBackUrl").val(obj.todoContent); + $("#urlCall").val(confArg.urlInfo.urlCall); }else { - $("#emailTemplate").val(obj.todoContent); + $("#mailTo").val(confArg.mailInfo.mailTo); + $("#mailCc").val(confArg.mailInfo.mailCc); + $("#mailTemp").val(confArg.mailInfo.mailTemp); } $("#ruleId").val(obj.ruleId); $("#crtRuleBtn").text("修改规则"); @@ -230,10 +246,10 @@ $("#todoType").bind("change",function(){ if($(this).val() == 0){ - $("#emailTemplateDiv").show(); + $("#mailTempDiv").show(); $("#callBackDiv").hide(); }else if($(this).val() == 1){ - $("#emailTemplateDiv").hide(); + $("#mailTempDiv").hide(); $("#callBackDiv").show(); } }); @@ -266,13 +282,15 @@ if(result == 'OK'){ $("#appName").text(appCode); var obj = jQuery.parseJSON(data.data); - var periodJson = jQuery.parseJSON(obj.configArgs); - $("#period").val(periodJson.period); + var confArg = jQuery.parseJSON(obj.configArgs); + $("#period").val(confArg.period); + $("#todoType").val(obj.todoType).change(); if(obj.todoType == 1){ - $("#todoType").val(obj.todoType).change(); - $("#callBackUrl").val(obj.todoContent); + $("#urlCall").val(confArg.urlInfo.urlCall); }else { - $("#emailTemplate").val(obj.todoContent); + $("#mailTo").val(confArg.mailInfo.mailTo); + $("#mailCc").val(confArg.mailInfo.mailCc); + $("#mailTemp").val(confArg.mailInfo.mailTemp); } $("#ruleId").val(obj.ruleId); $("#crtRuleBtn").text("修改规则"); @@ -281,8 +299,10 @@ $("#appName").html(appCode+"(使用默认规则)"); $("#period").val(""); $("#todoType").val("0").change(); - $("#callBackUrl").val(""); - $("#emailTemplate").val(""); + $("#urlCall").val(""); + $("#mailTo").val(""); + $("#mailCc").val(""); + $("#mailTemp").val(""); $("#ruleId").val(""); $("#crtRuleBtn").text("创建规则"); $("#cannelRuleBtn").text("取消创建"); @@ -295,9 +315,9 @@ }); }); + //创建规则操作 $("#crtRuleBtn").bind("click",function(){ var ruleId = $("#ruleId").val(); - var appId = $("#appId").val();//可空 var period = $("#period").val();//不可空 if(period == null || period.length < 1){ @@ -322,21 +342,24 @@ alert("告警操作不能为空"); return false; } - var callBackUrl = $("#callBackUrl").val(); - var emailTemplate = $("#emailTemplate").val(); + var urlCall = $("#urlCall").val(); + var mailTemp = $("#mailTemp").val(); var todoContent = ""; - if(todoType == 1){ - if(callBackUrl == null || callBackUrl.length < 1){ - alert("回调接口不能为空"); - return false; - } - todoContent = callBackUrl; - }else{ - if(emailTemplate == null || emailTemplate.length < 1){ + if(todoType == 0){ + if(mailTemp == null || mailTemp.length < 1){ alert("邮件模板不能为空"); return false; } - todoContent = emailTemplate; + var mailTo = $("#mailTo").val(); + var mailCc = $("#mailCc").val(); + }else if(todoType == 1){ + if(urlCall == null || urlCall.length < 1){ + alert("回调接口不能为空"); + return false; + } + }else{ + alert("告警规则不能为空"); + return false; } var ruleId = $("#ruleId").val(); var jsonData = ""; @@ -347,7 +370,15 @@ return false; } var urlStr = '${base}/alarmRule/modify'; - jsonData = "{ruleId:'"+ruleId+"',appId:'"+appId+"',period:'"+period+"',isGlobal:'"+isGlobal+"',todoType:'"+todoType+"',todoContent:'"+todoContent+"'}"; + if(todoType ==0){ + jsonData = "{ruleId:'"+ruleId+"',appId:'"+appId+"',period:'"+period+"',isGlobal:'"+isGlobal+"',todoType:'"+todoType+"',mailTemp:'"+mailTemp+"',mailTo:'"+mailTo+"',mailCc:'"+mailCc+"'}"; + }else if(todoType ==1){ + jsonData = "{ruleId:'"+ruleId+"',appId:'"+appId+"',period:'"+period+"',isGlobal:'"+isGlobal+"',todoType:'"+todoType+"',urlCall:'"+urlCall+"'}"; + }else{ + alert("请选择正确的告警操作"); + return false; + } + alert(jsonData); $.ajax({ type: 'POST', url: urlStr, @@ -370,7 +401,15 @@ }else{ //调用创建规则 var urlStr = '${base}/alarmRule/create'; - jsonData = "{appId:'"+appId+"',period:'"+period+"',isGlobal:'"+isGlobal+"',todoType:'"+todoType+"',todoContent:'"+todoContent+"'}"; + if(todoType ==0){ + jsonData = "{appId:'"+appId+"',period:'"+period+"',isGlobal:'"+isGlobal+"',todoType:'"+todoType+"',mailTemp:'"+mailTemp+"',mailTo:'"+mailTo+"',mailCc:'"+mailCc+"'}"; + }else if(todoType ==1){ + jsonData = "{appId:'"+appId+"',period:'"+period+"',isGlobal:'"+isGlobal+"',todoType:'"+todoType+"',urlCall:'"+urlCall+"'}"; + }else{ + alert("请选择正确的告警操作"); + return false; + } + alert(jsonData); $.ajax({ type: 'POST', url: urlStr, diff --git a/skywalking-webui/src/main/webapp/ftl/lib/ai.cloud/common.ftl b/skywalking-webui/src/main/webapp/ftl/lib/ai.cloud/common.ftl index a9d9f402a..4f31b9810 100644 --- a/skywalking-webui/src/main/webapp/ftl/lib/ai.cloud/common.ftl +++ b/skywalking-webui/src/main/webapp/ftl/lib/ai.cloud/common.ftl @@ -74,7 +74,7 @@ ${userInfo}
${traceId!}
- 调度入口IP:${(valueList[0].address)!},开始时间:${beginTime?number_to_datetime},${(valueList?size)!}条调用记录,消耗总时长:${(endTime - beginTime)!'0'} ms.显示原文 + 调度入口IP:${(valueList[0].address)!},开始时间:${beginTime?number_to_datetime},${(valueList?size)!}条调用记录,消耗总时长:${(endTime - beginTime)!'0'} ms。显示原文