diff --git a/skywalking-webui/pom.xml b/skywalking-webui/pom.xml
index 13fb935b3..13bbb9d1d 100644
--- a/skywalking-webui/pom.xml
+++ b/skywalking-webui/pom.xml
@@ -114,5 +114,10 @@
aspectjweaver
1.8.7
+
+ com.ai.cloud
+ skywalking-alarm
+ 1.0-SNAPSHOT
+
\ No newline at end of file
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 f50af2aee..c920c2b40 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,359 +1,343 @@
package com.ai.cloud.controller;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.ModelMap;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
-
import com.ai.cloud.service.inter.IAlarmRuleSer;
import com.ai.cloud.util.Constants;
import com.ai.cloud.util.common.StringUtil;
import com.ai.cloud.vo.mvo.AlarmRuleMVO;
+import com.ai.cloud.vo.svo.ConfigArgs;
+import com.ai.cloud.vo.svo.MailInfo;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
-import com.sun.activation.registries.MailcapTokenizer;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
@Controller
public class AlarmRuleCtl {
- @Autowired
- IAlarmRuleSer alarmRuleSer;
+ @Autowired
+ IAlarmRuleSer alarmRuleSer;
- private static Logger logger = LogManager.getLogger(AlarmRuleCtl.class);
+ private static Logger logger = LogManager.getLogger(AlarmRuleCtl.class);
- /***
- * 查询用户默认规则
- *
- * @param root
- * @return
- * @throws Exception
- */
- @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 {
- HttpSession session = request.getSession();
- String uid = (String) session.getAttribute("uid");
+ /***
+ * 查询用户默认规则
+ *
+ * @param root
+ * @return
+ * @throws Exception
+ */
+ @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 {
+ HttpSession session = request.getSession();
+ String uid = (String) session.getAttribute("uid");
- JSONObject reJson = new JSONObject();
+ JSONObject reJson = new JSONObject();
- if (StringUtil.isBlank(uid)) {
- reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL);
- reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "用户会话超时");
- return reJson.toJSONString();
- }
+ if (StringUtil.isBlank(uid)) {
+ reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL);
+ reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "用户会话超时");
+ return reJson.toJSONString();
+ }
- AlarmRuleMVO ruleMVO = new AlarmRuleMVO();
- ruleMVO.setUid(uid);
+ AlarmRuleMVO ruleMVO = new AlarmRuleMVO();
+ ruleMVO.setUid(uid);
- ruleMVO = alarmRuleSer.queryUserDefaultAlarmRule(ruleMVO);
+ 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, "查询到默认数据");
- reJson.put(Constants.JSON_RESULT_KEY_RESULT_DATA, JSON.toJSONString(ruleMVO));
- } else {
- reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL);
- reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未查询到默认数据");
- }
+ 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, "查询到默认数据");
+ reJson.put(Constants.JSON_RESULT_KEY_RESULT_DATA, JSON.toJSONString(ruleMVO));
+ } else {
+ reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL);
+ reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未查询到默认数据");
+ }
- return reJson.toJSONString();
- }
+ return reJson.toJSONString();
+ }
- /***
- * 查询用户默认规则
- *
- * @param root
- * @return
- * @throws Exception
- */
- @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 {
- HttpSession session = request.getSession();
- String uid = (String) session.getAttribute("uid");
+ /***
+ * 查询用户默认规则
+ *
+ * @param root
+ * @return
+ * @throws Exception
+ */
+ @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 {
+ HttpSession session = request.getSession();
+ String uid = (String) session.getAttribute("uid");
- JSONObject reJson = new JSONObject();
+ JSONObject reJson = new JSONObject();
- if (StringUtil.isBlank(uid)) {
- reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL);
- reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "用户会话超时");
- return reJson.toJSONString();
- }
+ if (StringUtil.isBlank(uid)) {
+ reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL);
+ reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "用户会话超时");
+ return reJson.toJSONString();
+ }
- AlarmRuleMVO ruleMVO = new AlarmRuleMVO();
- ruleMVO.setAppId(appId);
- ruleMVO.setUid(uid);
+ AlarmRuleMVO ruleMVO = new AlarmRuleMVO();
+ ruleMVO.setAppId(appId);
+ ruleMVO.setUid(uid);
- ruleMVO = alarmRuleSer.queryAppAlarmRule(ruleMVO);
+ ruleMVO = alarmRuleSer.queryAppAlarmRule(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, "查询到默认数据");
- reJson.put(Constants.JSON_RESULT_KEY_RESULT_DATA, JSON.toJSONString(ruleMVO));
- } else {
- reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL);
- reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未查询到默认数据");
- }
+ 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, "查询到默认数据");
+ reJson.put(Constants.JSON_RESULT_KEY_RESULT_DATA, JSON.toJSONString(ruleMVO));
+ } else {
+ reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL);
+ reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未查询到默认数据");
+ }
- return reJson.toJSONString();
- }
+ return reJson.toJSONString();
+ }
- /***
- * 创建用户默认规则
- *
- * @param root
- * @return
- * @throws Exception
- */
- @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 {
- HttpSession session = request.getSession();
- String uid = (String) session.getAttribute("uid");
+ /***
+ * 创建用户默认规则
+ *
+ * @param root
+ * @return
+ * @throws Exception
+ */
+ @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 {
+ HttpSession session = request.getSession();
+ String uid = (String) session.getAttribute("uid");
- JSONObject reJson = new JSONObject();
+ JSONObject reJson = new JSONObject();
- if (StringUtil.isBlank(uid)) {
- reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL);
- reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "用户会话超时");
- return reJson.toJSONString();
- }
+ if (StringUtil.isBlank(uid)) {
+ reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL);
+ reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "用户会话超时");
+ return reJson.toJSONString();
+ }
- JSONObject json = JSON.parseObject(jsonStr);
- 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")) {
- 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")) {
- 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");
+ JSONObject json = JSON.parseObject(jsonStr);
+ 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")) {
+ 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")) {
+ 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");
- 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", "");
- }
- } 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);
- reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未定义告警操作类型");
- return reJson.toJSONString();
- }
+ 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", "");
+ }
+ } 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);
+ reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未定义告警操作类型");
+ return reJson.toJSONString();
+ }
- AlarmRuleMVO srchRuleMVO = new AlarmRuleMVO();
- srchRuleMVO.setUid(uid);
- srchRuleMVO.setSts(Constants.STR_VAL_A);
- srchRuleMVO.setIsGlobal(isGlobal);
+ AlarmRuleMVO srchRuleMVO = new AlarmRuleMVO();
+ srchRuleMVO.setUid(uid);
+ srchRuleMVO.setSts(Constants.STR_VAL_A);
+ srchRuleMVO.setIsGlobal(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")) {
- 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 {
- srchRuleMVO.setAppId(json.getString("appId"));
- srchRuleMVO = alarmRuleSer.queryAppAlarmRule(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();
- }
- }
- }
+ // 判断是否为全局规则
+ 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")) {
+ 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 {
+ srchRuleMVO.setAppId(json.getString("appId"));
+ srchRuleMVO = alarmRuleSer.queryAppAlarmRule(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();
+ }
+ }
+ }
- AlarmRuleMVO ruleMVO = new AlarmRuleMVO();
- ruleMVO.setUid(uid);
- ruleMVO.setAppId(json.getString("appId"));
- ruleMVO.setSts(Constants.STR_VAL_A);
- ruleMVO.setIsGlobal(isGlobal);
- ruleMVO.setTodoType(todoType);
- JSONObject confArgs = new JSONObject();
- confArgs.put("period", period);
- if (Constants.TODO_TYPE_0.equals(todoType)) {
- // 设置邮件相关的信息
- JSONObject mailInfo = new JSONObject();
+ AlarmRuleMVO ruleMVO = new AlarmRuleMVO();
+ ruleMVO.setUid(uid);
+ ruleMVO.setAppId(json.getString("appId"));
+ ruleMVO.setSts(Constants.STR_VAL_A);
+ ruleMVO.setIsGlobal(isGlobal);
+ ruleMVO.setTodoType(todoType);
+ 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);
+ String[] mailToList = mailTo.split(Constants.MAIL_SPLIT_CHAR);
- if (!StringUtil.isBlank(mailCc)) {
- String[] mailCcList = mailCc.split(Constants.MAIL_SPLIT_CHAR);
- mailInfo.put("mailCc", mailCcList);
- }
+ if (!StringUtil.isBlank(mailCc)) {
+ String[] mailCcList = mailCc.split(Constants.MAIL_SPLIT_CHAR);
+ mailInfo.put("mailCc", mailCcList);
+ }
- mailInfo.put("mailTo", mailToList);
- 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);
- }
+ mailInfo.put("mailTo", mailToList);
+ 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());
+ ConfigArgs configArgs = new ConfigArgs();
+ configArgs.setPeriod(json.getInteger("period"));
+ MailInfo mailInfo = new MailInfo();
+ mailInfo.setMailCc(json.getString("mailCc").toString().trim().split(","));
+ mailInfo.setMailTo(json.getString("mailTo").toString().trim().split(","));
+ configArgs.setMailInfo(mailInfo);
+ ruleMVO.setConfigArgs(configArgs);
- 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, "操作成功");
+ 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) {
- 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();
- }
+ } 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();
+ }
- /***
- * 创建用户默认规则
- *
- * @param root
- * @return
- * @throws Exception
- */
- @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 {
- HttpSession session = request.getSession();
- String uid = (String) session.getAttribute("uid");
+ /***
+ * 创建用户默认规则
+ *
+ * @param root
+ * @return
+ * @throws Exception
+ */
+ @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 {
+ HttpSession session = request.getSession();
+ String uid = (String) session.getAttribute("uid");
- JSONObject reJson = new JSONObject();
+ JSONObject reJson = new JSONObject();
- if (StringUtil.isBlank(uid)) {
- reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL);
- reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "用户会话超时");
- return reJson.toJSONString();
- }
+ if (StringUtil.isBlank(uid)) {
+ reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL);
+ reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "用户会话超时");
+ return reJson.toJSONString();
+ }
- JSONObject json = JSON.parseObject(jsonStr);
- 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")) {
- 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")) {
- 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")) {
- 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");
- 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", "");
- }
- } 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);
- reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未定义告警操作类型");
- return reJson.toJSONString();
- }
+ JSONObject json = JSON.parseObject(jsonStr);
+ 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")) {
+ 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")) {
+ 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")) {
+ 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");
+ 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", "");
+ }
+ } 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);
+ reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未定义告警操作类型");
+ return reJson.toJSONString();
+ }
- AlarmRuleMVO ruleMVO = new AlarmRuleMVO();
- ruleMVO.setRuleId(ruleId);
- ruleMVO.setTodoType(todoType);
- JSONObject confArgs = new JSONObject();
- confArgs.put("period", period);
- if (Constants.TODO_TYPE_0.equals(todoType)) {
- // 设置邮件相关的信息
- JSONObject mailInfo = new JSONObject();
+ AlarmRuleMVO ruleMVO = new AlarmRuleMVO();
+ ruleMVO.setRuleId(ruleId);
+ ruleMVO.setTodoType(todoType);
+ ConfigArgs configArgs = new ConfigArgs();
+ configArgs.setPeriod(json.getInteger("period"));
+ MailInfo mailInfo = new MailInfo();
+ mailInfo.setMailCc(json.getString("mailCc").toString().trim().split(","));
+ mailInfo.setMailTo(json.getString("mailTo").toString().trim().split(","));
+ configArgs.setMailInfo(mailInfo);
+ ruleMVO.setConfigArgs(configArgs);
- String[] mailToList = mailTo.split(Constants.MAIL_SPLIT_CHAR);
+ 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, "操作成功");
- if (!StringUtil.isBlank(mailCc)) {
- String[] mailCcList = mailCc.split(Constants.MAIL_SPLIT_CHAR);
- mailInfo.put("mailCc", mailCcList);
- }
-
- mailInfo.put("mailTo", mailToList);
- 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 {
- 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) {
- 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();
- }
+ } 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();
+ }
}
diff --git a/skywalking-webui/src/main/java/com/ai/cloud/controller/AlarmRuleMaintainCtl.java b/skywalking-webui/src/main/java/com/ai/cloud/controller/AlarmRuleMaintainCtl.java
new file mode 100644
index 000000000..7ff477225
--- /dev/null
+++ b/skywalking-webui/src/main/java/com/ai/cloud/controller/AlarmRuleMaintainCtl.java
@@ -0,0 +1,51 @@
+package com.ai.cloud.controller;
+
+import com.ai.cloud.service.inter.IAlarmRuleSer;
+import com.ai.cloud.vo.mvo.AlarmRuleMVO;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+@Controller
+@RequestMapping("/alarm-rule")
+public class AlarmRuleMaintainCtl {
+
+ @Autowired
+ IAlarmRuleSer alarmRuleSer;
+
+ private static Logger logger = LogManager.getLogger(AlarmRuleMaintainCtl.class);
+
+ @RequestMapping("/toCreate")
+ public String create() {
+ return "alarm-rule/createAlarm-rule";
+ }
+
+ @RequestMapping("/list/{appId}")
+ public String listInfo(HttpServletRequest request, ModelMap model, @PathVariable("appId") String appId, String ruleId, String appCode,String isGlobal) {
+ HttpSession session = request.getSession();
+ String uid = (String) session.getAttribute("uid");
+ AlarmRuleMVO ruleMVO = new AlarmRuleMVO();
+ if (!"default".equals(appId)) {
+ ruleMVO.setAppId(appId);
+ }
+ ruleMVO.setUid(uid);
+ if (!"default".equals(appId)) {
+ ruleMVO = alarmRuleSer.queryAppAlarmRule(ruleMVO);
+ ruleMVO.setAppId(appId);
+ } else {
+ ruleMVO = alarmRuleSer.queryUserDefaultAlarmRule(ruleMVO);
+ }
+
+ ruleMVO.setAppCode(appCode);
+ model.addAttribute("ruleMVO", ruleMVO);
+ ruleMVO.setIsGlobal(isGlobal);
+ return "alarm-rule/createAlarm-rule";
+ }
+}
diff --git a/skywalking-webui/src/main/java/com/ai/cloud/controller/AppMaintainCtl.java b/skywalking-webui/src/main/java/com/ai/cloud/controller/AppMaintainCtl.java
new file mode 100644
index 000000000..3554bdce9
--- /dev/null
+++ b/skywalking-webui/src/main/java/com/ai/cloud/controller/AppMaintainCtl.java
@@ -0,0 +1,14 @@
+package com.ai.cloud.controller;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.servlet.ModelAndView;
+
+@Controller
+@RequestMapping("/app")
+public class AppMaintainCtl {
+ @RequestMapping("/create")
+ public String create() {
+ return "app/createApp";
+ }
+}
diff --git a/skywalking-webui/src/main/java/com/ai/cloud/controller/AuthFileCtl.java b/skywalking-webui/src/main/java/com/ai/cloud/controller/AuthFileCtl.java
index fe82d1d39..5fd630d12 100644
--- a/skywalking-webui/src/main/java/com/ai/cloud/controller/AuthFileCtl.java
+++ b/skywalking-webui/src/main/java/com/ai/cloud/controller/AuthFileCtl.java
@@ -9,6 +9,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -64,8 +65,8 @@ public class AuthFileCtl {
continue;
}
- if (propertyValue.startsWith("$")){
- if (request.getParameter((propertyValue.substring(1))) != null ) {
+ if (propertyValue.startsWith("$")) {
+ if (request.getParameter((propertyValue.substring(1))) != null) {
value.setValue(request.getParameter(propertyValue.substring(1)));
}
}
@@ -112,4 +113,10 @@ public class AuthFileCtl {
return reJson.toJSONString();
}
+
+ @RequestMapping("/download/{appCode}")
+ public String toDownloadAuthFile(@PathVariable("appCode") String appCode, ModelMap root) throws Exception {
+ root.addAttribute("appCode", appCode);
+ return "auth-file/authFile";
+ }
}
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 1ad5c8aa6..88c007013 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
@@ -1,11 +1,9 @@
package com.ai.cloud.dao.impl;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
+import com.ai.cloud.dao.inter.IAlarmRuleMDAO;
+import com.ai.cloud.vo.mvo.AlarmRuleMVO;
+import com.ai.cloud.vo.svo.ConfigArgs;
+import com.google.gson.Gson;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
@@ -16,103 +14,102 @@ import org.springframework.jdbc.support.GeneratedKeyHolder;
import org.springframework.jdbc.support.KeyHolder;
import org.springframework.stereotype.Repository;
-import com.ai.cloud.dao.inter.IAlarmRuleMDAO;
-import com.ai.cloud.vo.mvo.AlarmRuleMVO;
+import java.sql.*;
@Repository
public class AlarmRuleMDAO implements IAlarmRuleMDAO {
- @Autowired
- private JdbcTemplate jdbcTemplate;
+ @Autowired
+ private JdbcTemplate jdbcTemplate;
- private static Logger logger = LogManager.getLogger(AlarmRuleMDAO.class);
+ private static Logger logger = LogManager.getLogger(AlarmRuleMDAO.class);
- @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,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
- public void processRow(ResultSet rs) throws SQLException {
- ruleMVO.setRuleId(rs.getString("rule_id"));
- ruleMVO.setAppId(rs.getString("app_id"));
- ruleMVO.setUid(rs.getString("uid"));
- ruleMVO.setConfigArgs(rs.getString("config_args"));
- ruleMVO.setIsGlobal(rs.getString("is_global"));
- ruleMVO.setTodoType(rs.getString("todo_type"));
- ruleMVO.setCreateTime(rs.getTimestamp("create_time"));
- ruleMVO.setSts(rs.getString("sts"));
- ruleMVO.setModifyTime(rs.getTimestamp("modify_time"));
- }
- });
- logger.info("result : {}", ruleMVO);
- return ruleMVO;
- }
+ @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,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
+ public void processRow(ResultSet rs) throws SQLException {
+ ruleMVO.setRuleId(rs.getString("rule_id"));
+ ruleMVO.setAppId(rs.getString("app_id"));
+ ruleMVO.setUid(rs.getString("uid"));
+ ruleMVO.setConfigArgs(new Gson().fromJson(rs.getString("config_args"), ConfigArgs.class));
+ ruleMVO.setIsGlobal(rs.getString("is_global"));
+ ruleMVO.setTodoType(rs.getString("todo_type"));
+ ruleMVO.setCreateTime(rs.getTimestamp("create_time"));
+ ruleMVO.setSts(rs.getString("sts"));
+ ruleMVO.setModifyTime(rs.getTimestamp("modify_time"));
+ }
+ });
+ logger.info("result : {}", ruleMVO);
+ return ruleMVO;
+ }
- @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,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
- public void processRow(ResultSet rs) throws SQLException {
- ruleMVO.setRuleId(rs.getString("rule_id"));
- ruleMVO.setAppId(rs.getString("app_id"));
- ruleMVO.setUid(rs.getString("uid"));
- ruleMVO.setConfigArgs(rs.getString("config_args"));
- ruleMVO.setIsGlobal(rs.getString("is_global"));
- ruleMVO.setTodoType(rs.getString("todo_type"));
- ruleMVO.setCreateTime(rs.getTimestamp("create_time"));
- ruleMVO.setSts(rs.getString("sts"));
- ruleMVO.setModifyTime(rs.getTimestamp("modify_time"));
- }
- });
- logger.info("result : {}", ruleMVO);
- return ruleMVO;
- }
+ @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,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
+ public void processRow(ResultSet rs) throws SQLException {
+ ruleMVO.setRuleId(rs.getString("rule_id"));
+ ruleMVO.setAppId(rs.getString("app_id"));
+ ruleMVO.setUid(rs.getString("uid"));
+ ruleMVO.setConfigArgs(new Gson().fromJson(rs.getString("config_args"), ConfigArgs.class));
+ ruleMVO.setIsGlobal(rs.getString("is_global"));
+ ruleMVO.setTodoType(rs.getString("todo_type"));
+ ruleMVO.setCreateTime(rs.getTimestamp("create_time"));
+ ruleMVO.setSts(rs.getString("sts"));
+ ruleMVO.setModifyTime(rs.getTimestamp("modify_time"));
+ }
+ });
+ logger.info("result : {}", ruleMVO);
+ return ruleMVO;
+ }
- @Override
- public AlarmRuleMVO createAlarmRule(final AlarmRuleMVO ruleMVO) {
- 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();
+ @Override
+ public AlarmRuleMVO createAlarmRule(final AlarmRuleMVO ruleMVO) {
+ 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() {
- public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
- PreparedStatement pstmt = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
- int i = 0;
- pstmt.setString(++i, ruleMVO.getAppId());
- pstmt.setString(++i, ruleMVO.getUid());
- pstmt.setString(++i, ruleMVO.getConfigArgs());
- pstmt.setString(++i, ruleMVO.getIsGlobal());
- pstmt.setString(++i, ruleMVO.getTodoType());
- pstmt.setString(++i, ruleMVO.getSts());
- return pstmt;
- }
- }, keyHolder);
- logger.info("创建应用成功:{}", keyHolder.getKey().intValue());
- ruleMVO.setRuleId(keyHolder.getKey().toString());
+ int count = jdbcTemplate.update(new PreparedStatementCreator() {
+ public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
+ PreparedStatement pstmt = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
+ int i = 0;
+ pstmt.setString(++i, ruleMVO.getAppId());
+ pstmt.setString(++i, ruleMVO.getUid());
+ pstmt.setString(++i, new Gson().toJson(ruleMVO.getConfigArgs()));
+ pstmt.setString(++i, ruleMVO.getIsGlobal());
+ pstmt.setString(++i, ruleMVO.getTodoType());
+ pstmt.setString(++i, ruleMVO.getSts());
+ return pstmt;
+ }
+ }, keyHolder);
+ logger.info("创建应用成功:{}", keyHolder.getKey().intValue());
+ ruleMVO.setRuleId(keyHolder.getKey().toString());
- return ruleMVO;
- }
+ return ruleMVO;
+ }
- @Override
- public AlarmRuleMVO modifyAlarmRule(final AlarmRuleMVO ruleMVO) {
- final String sql = "update alarm_rule set config_args = ?,todo_type = ? where rule_id = ?";
+ @Override
+ public AlarmRuleMVO modifyAlarmRule(final AlarmRuleMVO ruleMVO) {
+ 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 {
- PreparedStatement pstmt = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
- int i = 0;
- pstmt.setString(++i, ruleMVO.getConfigArgs());
- pstmt.setString(++i, ruleMVO.getTodoType());
- pstmt.setString(++i, ruleMVO.getRuleId());
- return pstmt;
- }
- });
+ int count = jdbcTemplate.update(new PreparedStatementCreator() {
+ public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
+ PreparedStatement pstmt = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
+ int i = 0;
+ pstmt.setString(++i, new Gson().toJson(ruleMVO.getConfigArgs()));
+ pstmt.setString(++i, ruleMVO.getTodoType());
+ pstmt.setString(++i, ruleMVO.getRuleId());
+ return pstmt;
+ }
+ });
- return ruleMVO;
- }
+ return ruleMVO;
+ }
}
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 530be2073..09cac1abf 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
@@ -3,7 +3,9 @@ package com.ai.cloud.vo.svo;
import java.sql.Timestamp;
public class AlarmRuleSVO {
-
+
+ private String appCode;
+
private String ruleId;
private String appId;
@@ -13,8 +15,8 @@ public class AlarmRuleSVO {
private String isGlobal;
private String todoType;
-
- private String configArgs;
+
+ private ConfigArgs configArgs;
private Timestamp createTime;
@@ -46,11 +48,11 @@ public class AlarmRuleSVO {
this.uid = uid;
}
- public String getConfigArgs() {
+ public ConfigArgs getConfigArgs() {
return configArgs;
}
- public void setConfigArgs(String configArgs) {
+ public void setConfigArgs(ConfigArgs configArgs) {
this.configArgs = configArgs;
}
@@ -101,4 +103,11 @@ public class AlarmRuleSVO {
+ sts + ", modifyTime=" + modifyTime + "]";
}
+ public String getAppCode() {
+ return appCode;
+ }
+
+ public void setAppCode(String appCode) {
+ this.appCode = appCode;
+ }
}
diff --git a/skywalking-webui/src/main/java/com/ai/cloud/vo/svo/ConfigArgs.java b/skywalking-webui/src/main/java/com/ai/cloud/vo/svo/ConfigArgs.java
new file mode 100644
index 000000000..8f9e55b28
--- /dev/null
+++ b/skywalking-webui/src/main/java/com/ai/cloud/vo/svo/ConfigArgs.java
@@ -0,0 +1,26 @@
+package com.ai.cloud.vo.svo;
+
+import java.io.Serializable;
+
+public class ConfigArgs implements Serializable {
+
+ private int period;
+
+ private MailInfo mailInfo;
+
+ public MailInfo getMailInfo() {
+ return mailInfo;
+ }
+
+ public void setMailInfo(MailInfo mailInfo) {
+ this.mailInfo = mailInfo;
+ }
+
+ public int getPeriod() {
+ return period;
+ }
+
+ public void setPeriod(int period) {
+ this.period = period;
+ }
+}
diff --git a/skywalking-webui/src/main/java/com/ai/cloud/vo/svo/MailInfo.java b/skywalking-webui/src/main/java/com/ai/cloud/vo/svo/MailInfo.java
new file mode 100644
index 000000000..d3e3d500f
--- /dev/null
+++ b/skywalking-webui/src/main/java/com/ai/cloud/vo/svo/MailInfo.java
@@ -0,0 +1,24 @@
+package com.ai.cloud.vo.svo;
+
+import java.io.Serializable;
+
+public class MailInfo implements Serializable {
+ private String[] mailTo;
+ private String[] mailCc;
+
+ public String[] getMailTo() {
+ return mailTo;
+ }
+
+ public void setMailTo(String[] mailTo) {
+ this.mailTo = mailTo;
+ }
+
+ public String[] getMailCc() {
+ return mailCc;
+ }
+
+ public void setMailCc(String[] mailCc) {
+ this.mailCc = mailCc;
+ }
+}
diff --git a/skywalking-webui/src/main/resources/jdbc.properties b/skywalking-webui/src/main/resources/jdbc.properties
index fcbb2a288..2cbdf3dac 100644
--- a/skywalking-webui/src/main/resources/jdbc.properties
+++ b/skywalking-webui/src/main/resources/jdbc.properties
@@ -1,7 +1,7 @@
jdbc.driverClassName=com.mysql.jdbc.Driver
-jdbc.url=jdbc:mysql://10.1.241.20:31306/sw_db
-jdbc.username=sw_dbusr01
-jdbc.password=sw_dbusr01
+jdbc.url=jdbc:mysql://10.1.228.202:31316/test
+jdbc.username=devrdbusr21
+jdbc.password=devrdbusr21
jdbc.maxTotal=200
jdbc.maxIdle=50
jdbc.maxWaitMillis=1000
diff --git a/skywalking-webui/src/main/sql/table.mysql b/skywalking-webui/src/main/sql/table.mysql
index adba9b244..dacdded12 100644
--- a/skywalking-webui/src/main/sql/table.mysql
+++ b/skywalking-webui/src/main/sql/table.mysql
@@ -194,3 +194,34 @@ ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
+
+
+CREATE TABLE `test`.`auth_file_config` (
+ `config_id` INT(11) NOT NULL,
+ `key` VARCHAR(200) NOT NULL,
+ `value0` VARCHAR(200) NULL,
+ `value1` VARCHAR(200) NULL DEFAULT NULL,
+ `value2` VARCHAR(200) NULL DEFAULT NULL,
+ `value3` VARCHAR(200) NULL DEFAULT NULL,
+ `value4` VARCHAR(200) NULL DEFAULT NULL,
+ `key_desc` VARCHAR(500) NULL,
+ `sts` VARCHAR(2) NULL,
+ PRIMARY KEY (`config_id`));
+
+
+INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('1', 'buriedpoint.printf', 'false', 'false', '是否打印数据', 'A');
+INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('2', 'buriedpoint.max_exception_stack_length', '4000', '4000', '埋点异常的最大长度', 'A');
+INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('3', 'buriedpoint.businesskey_max_length', '300', '300', '业务字段的最大长度', 'A');
+INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('4', 'buriedpoint.exclusive_exceptions', '$exclusiveException', '$exclusiveException', '过滤异常', 'A');
+INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('5', 'sender.connect_percent', '100', '100', '最大发送者的连接数阀比例', 'A');
+INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('6', 'sender.servers_addr', '#servers_addr', '#servers_addr_1', '发送服务端配置', 'A');
+INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('7', 'sender.max_copy_num', '2', '2', '最大发送的副本数量', 'A');
+INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('8', 'sender.max_send_length', '20000', '20000', '发送的最大长度', 'A');
+INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('9', 'sender.retry_get_sender_wait_interval', '2000', '2000', '当没有Sender时,尝试获取sender的等待周期', 'A');
+INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('10', 'sender.is_off', 'false', 'false', '是否开启发送消息', 'A');
+INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('11', 'consumer.max_consumer', '2', '2', '最大消费线程数', 'A');
+INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('12', 'consumer.max_wait_time', '5', '5', '消费者最大等待时间', 'A');
+INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('13', 'consumer.consumer_fail_retry_wait_interval', '50', '50', '发送失败等待时间 ', 'A');
+INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('14', 'buffer.buffer_max_size', '18000', '18000', '每个Buffer的最大个数', 'A');
+INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('15', 'buffer.pool_size', '5', '5', 'Buffer池的最大长度', 'A');
+INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('16', 'senderchecker.check_polling_time', '200', '200', '发送检查线程检查周期', 'A');
\ No newline at end of file
diff --git a/skywalking-webui/src/main/webapp/css/traceLog.css b/skywalking-webui/src/main/webapp/css/traceLog.css
index 68ad03612..6d34baf56 100644
--- a/skywalking-webui/src/main/webapp/css/traceLog.css
+++ b/skywalking-webui/src/main/webapp/css/traceLog.css
@@ -1,31 +1,37 @@
body {
- background:#EEEEEE
+ background: #EEEEEE
}
.progress {
- height: 15px;
- margin-bottom:0px;
+ height: 15px;
+ margin-bottom: 0px;
}
+
.progress-bar {
- font-size: 10px;
- line-height:15px;
-
+ font-size: 10px;
+ line-height: 15px;
+ background-color: transparent;
}
+
.progress-bar-white {
- background-image: none;
- background-color: #FFFFFF;
+ background-image: none;
+ background-color: #FFFFFF;
}
-.highlight {
- background-color: #D8ECF6;
+
+.highlight {
+ background-color: #D8ECF6;
}
.progress-bar-a {
- background-color: #f0ad4e;
-}
-.progress-bar-b {
- background-color: #5cb85c;
-}
-.progress-bar-c {
- background-color: #5bc0de;
+ background-color: #f0ad4e;
}
+.progress-bar-b {
+ background-color: #5cb85c;
+}
+
+.progress-bar-c {
+ background-color: #5bc0de;
+}
+
+
diff --git a/skywalking-webui/src/main/webapp/ftl/alarm-rule/createAlarm-rule.ftl b/skywalking-webui/src/main/webapp/ftl/alarm-rule/createAlarm-rule.ftl
new file mode 100644
index 000000000..03ab442bf
--- /dev/null
+++ b/skywalking-webui/src/main/webapp/ftl/alarm-rule/createAlarm-rule.ftl
@@ -0,0 +1,59 @@
+<#import "../lib/ai.cloud/common.ftl" as common>
+
+
+
+
+
+ Sky Walking
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/skywalking-webui/src/main/webapp/ftl/app/createAPP.ftl b/skywalking-webui/src/main/webapp/ftl/app/createAPP.ftl
new file mode 100644
index 000000000..bcfb77ee6
--- /dev/null
+++ b/skywalking-webui/src/main/webapp/ftl/app/createAPP.ftl
@@ -0,0 +1,31 @@
+<#import "../lib/ai.cloud/common.ftl" as common>
+
+
+
+
+
+ Sky Walking
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/skywalking-webui/src/main/webapp/ftl/applist.ftl b/skywalking-webui/src/main/webapp/ftl/applist.ftl
index 9f5721ce9..953a58995 100644
--- a/skywalking-webui/src/main/webapp/ftl/applist.ftl
+++ b/skywalking-webui/src/main/webapp/ftl/applist.ftl
@@ -5,117 +5,29 @@
Sky Walking
-
+
-
+
+
+<@common.importJavaScript />
-
-
-
-
-
-
+
-
+
-
+
-
+
@@ -131,9 +43,14 @@
| ${appInfo_index + 1} |
${appInfo.appCode!} |
-
-
-
+
+
+
|
#list>
@@ -142,52 +59,68 @@
-
-<#---->
-
-<@common.importJavaScript />
+
+
+
+
+
+
+
+