Skip to content

Commit acbd845

Browse files
committed
add alert group
1 parent 4d12006 commit acbd845

File tree

15 files changed

+230
-24
lines changed

15 files changed

+230
-24
lines changed

kafka-eagle-api/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.smartloli.kafka.eagle</groupId>
66
<artifactId>kafka-eagle</artifactId>
7-
<version>1.3.9</version>
7+
<version>1.4.0</version>
88
</parent>
99
<artifactId>kafka-eagle-api</artifactId>
1010
<dependencies>

kafka-eagle-common/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.smartloli.kafka.eagle</groupId>
66
<artifactId>kafka-eagle</artifactId>
7-
<version>1.3.9</version>
7+
<version>1.4.0</version>
88
</parent>
99
<artifactId>kafka-eagle-common</artifactId>
1010

kafka-eagle-common/src/main/java/org/smartloli/kafka/eagle/common/util/KConstants.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public interface Topic {
182182
public final static int RUNNING = 0;
183183
public final static int SHUTDOWN = 1;
184184
public final static int PENDING = 2;
185-
185+
186186
public final static String RUNNING_STRING = "Running";
187187
public final static String SHUTDOWN_STRING = "Shutdown";
188188
public final static String PENDING_STRING = "Pending";
@@ -198,4 +198,8 @@ public interface Component {
198198

199199
}
200200

201+
public interface AlarmType {
202+
public static String[] TYPE = new String[] { "Email", "SMS", "DingDing", "Wechat", "WebHook" };
203+
}
204+
201205
}

kafka-eagle-core/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.smartloli.kafka.eagle</groupId>
66
<artifactId>kafka-eagle</artifactId>
7-
<version>1.3.9</version>
7+
<version>1.4.0</version>
88
</parent>
99
<artifactId>kafka-eagle-core</artifactId>
1010

kafka-eagle-plugin/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.smartloli.kafka.eagle</groupId>
66
<artifactId>kafka-eagle</artifactId>
7-
<version>1.3.9</version>
7+
<version>1.4.0</version>
88
</parent>
99
<artifactId>kafka-eagle-plugin</artifactId>
1010
<dependencies>

kafka-eagle-plugin/src/main/java/org/smartloli/kafka/eagle/plugin/font/KafkaEagleVersion.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static void main(String[] args) throws IOException {
3535
String asciiArt = FigletFont.convertOneLine(file, "KAfKA EAGLE");
3636
System.out.println("Welcome to");
3737
System.out.println(asciiArt);
38-
System.out.println("Version 1.3.9");
38+
System.out.println("Version 1.4.0");
3939
}
4040

4141
}

kafka-eagle-web/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.smartloli.kafka.eagle</groupId>
66
<artifactId>kafka-eagle</artifactId>
7-
<version>1.3.9</version>
7+
<version>1.4.0</version>
88
</parent>
99
<artifactId>kafka-eagle-web</artifactId>
1010
<packaging>war</packaging>

kafka-eagle-web/src/main/java/org/smartloli/kafka/eagle/web/controller/AlarmController.java

+28-7
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
import org.apache.shiro.authz.annotation.RequiresPermissions;
2929
import org.slf4j.Logger;
3030
import org.slf4j.LoggerFactory;
31+
import org.smartloli.kafka.eagle.common.protocol.AlertInfo;
32+
import org.smartloli.kafka.eagle.common.protocol.ClustersInfo;
33+
import org.smartloli.kafka.eagle.common.util.CalendarUtils;
34+
import org.smartloli.kafka.eagle.common.util.KConstants;
35+
import org.smartloli.kafka.eagle.common.util.SystemConfigUtils;
36+
import org.smartloli.kafka.eagle.web.service.AlertService;
3137
import org.springframework.beans.factory.annotation.Autowired;
3238
import org.springframework.stereotype.Controller;
3339
import org.springframework.web.bind.annotation.PathVariable;
@@ -39,13 +45,6 @@
3945
import com.alibaba.fastjson.JSONArray;
4046
import com.alibaba.fastjson.JSONObject;
4147

42-
import org.smartloli.kafka.eagle.common.protocol.AlertInfo;
43-
import org.smartloli.kafka.eagle.common.protocol.ClustersInfo;
44-
import org.smartloli.kafka.eagle.common.util.CalendarUtils;
45-
import org.smartloli.kafka.eagle.common.util.KConstants;
46-
import org.smartloli.kafka.eagle.common.util.SystemConfigUtils;
47-
import org.smartloli.kafka.eagle.web.service.AlertService;
48-
4948
/**
5049
* Alarm controller to viewer data.
5150
*
@@ -73,6 +72,15 @@ public ModelAndView addView(HttpSession session) {
7372
return mav;
7473
}
7574

75+
/** Add alarmer config group. */
76+
@RequiresPermissions("/alarm/config")
77+
@RequestMapping(value = "/alarm/config", method = RequestMethod.GET)
78+
public ModelAndView configView(HttpSession session) {
79+
ModelAndView mav = new ModelAndView();
80+
mav.setViewName("/alarm/config");
81+
return mav;
82+
}
83+
7684
/** Create cluster alarmer viewer. */
7785
@RequiresPermissions("/alarm/create")
7886
@RequestMapping(value = "/alarm/create", method = RequestMethod.GET)
@@ -447,4 +455,17 @@ public String modifyClusterAlertInfo(HttpSession session, HttpServletRequest req
447455
return "redirect:/errors/500";
448456
}
449457
}
458+
459+
/** Get alarm type list. */
460+
@RequestMapping(value = "/alarm/type/list/ajax", method = RequestMethod.GET)
461+
public void topicMockAjax(HttpServletResponse response, HttpServletRequest request) {
462+
try {
463+
JSONObject object = new JSONObject();
464+
object.put("items", JSON.parseArray(alertService.getAlertTypeList()));
465+
byte[] output = object.toJSONString().getBytes();
466+
BaseController.response(output, response);
467+
} catch (Exception ex) {
468+
ex.printStackTrace();
469+
}
470+
}
450471
}

kafka-eagle-web/src/main/java/org/smartloli/kafka/eagle/web/service/AlertService.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,22 @@ public interface AlertService {
6666

6767
/** List cluster information from alert. */
6868
public List<ClustersInfo> history(Map<String, Object> params);
69-
69+
7070
public int alertHistoryCount(Map<String, Object> params);
71-
71+
7272
/** Delete alert by id. */
7373
public int deleteClusterAlertById(int id);
74-
74+
7575
/** Find alert info by id. */
7676
public String findClusterAlertById(int id);
77-
77+
7878
/** Modify alert info by id. */
7979
public int modifyClusterAlertById(ClustersInfo cluster);
80-
80+
8181
/** Query clusters collector data. */
8282
public List<ClustersInfo> historys();
8383

84+
/** Get alert type list. */
85+
public String getAlertTypeList();
86+
8487
}

kafka-eagle-web/src/main/java/org/smartloli/kafka/eagle/web/service/impl/AlertServiceImpl.java

+16
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import org.smartloli.kafka.eagle.common.protocol.AlertInfo;
2525
import org.smartloli.kafka.eagle.common.protocol.ClustersInfo;
26+
import org.smartloli.kafka.eagle.common.util.KConstants.AlarmType;
2627
import org.smartloli.kafka.eagle.core.factory.KafkaFactory;
2728
import org.smartloli.kafka.eagle.core.factory.KafkaService;
2829
import org.smartloli.kafka.eagle.web.dao.AlertDao;
@@ -168,4 +169,19 @@ public List<ClustersInfo> historys() {
168169
return alertDao.historys();
169170
}
170171

172+
/** Get alert type list. */
173+
public String getAlertTypeList() {
174+
int offset = 0;
175+
JSONArray typeList = new JSONArray();
176+
for (String type : AlarmType.TYPE) {
177+
178+
JSONObject object = new JSONObject();
179+
object.put("text", type);
180+
object.put("id", offset);
181+
typeList.add(object);
182+
offset++;
183+
}
184+
return typeList.toJSONString();
185+
}
186+
171187
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<%@ page language="java" contentType="text/html; charset=UTF-8"
2+
pageEncoding="UTF-8"%>
3+
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
4+
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
5+
6+
<!DOCTYPE html>
7+
<html lang="zh">
8+
9+
<head>
10+
11+
<meta charset="utf-8">
12+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
13+
<meta name="viewport" content="width=device-width, initial-scale=1">
14+
<meta name="description" content="">
15+
<meta name="author" content="">
16+
17+
<title>Alarm - KafkaEagle</title>
18+
<jsp:include page="../public/css.jsp">
19+
<jsp:param value="plugins/select2/select2.min.css" name="css" />
20+
</jsp:include>
21+
</head>
22+
23+
<body>
24+
<jsp:include page="../public/navbar.jsp"></jsp:include>
25+
<div id="wrapper">
26+
<div id="page-wrapper">
27+
<div class="row">
28+
<div class="col-lg-12">
29+
<h1 class="page-header">
30+
Config <small>message</small>
31+
</h1>
32+
</div>
33+
<!-- /.col-lg-12 -->
34+
</div>
35+
<!-- /.row -->
36+
<div class="row">
37+
<div class="col-lg-12">
38+
<div class="alert alert-info alert-dismissable">
39+
<button type="button" class="close" data-dismiss="alert"
40+
aria-hidden="true">×</button>
41+
<i class="fa fa-info-circle"></i> <strong>Select kafka
42+
topic, then edit the simulation message, and then click send to
43+
produce the message.</strong>
44+
</div>
45+
</div>
46+
</div>
47+
<!-- /.row -->
48+
<div class="row">
49+
<div class="col-lg-12">
50+
<div class="panel panel-default">
51+
<div class="panel-heading">
52+
<i class="fa fa-cogs fa-fw"></i> Content
53+
<div class="pull-right"></div>
54+
</div>
55+
<!-- /.panel-heading -->
56+
<div class="panel-body">
57+
<div class="form-group">
58+
<label>Alarm Group Name (*)</label> <input
59+
id="ke_alarm_group_name" name="ke_alarm_group_name"
60+
class="form-control" placeholder="Enter Alarm Group Name">
61+
<label for="inputError" class="control-label text-danger"><i
62+
class="fa fa-info-circle"></i> Input the alarm group name .</label>
63+
</div>
64+
<div class="form-group">
65+
<label>Alarm Type (*)</label> <select id="select2val"
66+
name="select2val" tabindex="-1"
67+
style="width: 100%; font-family: 'Microsoft Yahei', 'HelveticaNeue', Helvetica, Arial, sans-serif; font-size: 1px;"></select>
68+
<input id="ke_alarm_type" name="ke_alarm_type" type="hidden" />
69+
<label for="inputError" class="control-label text-danger"><i
70+
class="fa fa-info-circle"></i> Select the type you need to
71+
alarm .</label>
72+
</div>
73+
<div class="form-group">
74+
<label>Message (*)</label>
75+
<textarea id="ke_mock_content" name="ke_mock_content"
76+
class="form-control" placeholder="Limit 120 words." rows="3"
77+
maxlength="120"></textarea>
78+
<label for="inputError" class="control-label text-danger"><i
79+
class="fa fa-info-circle"></i> Write something and send message
80+
to owner .</label>
81+
</div>
82+
<button type="button" class="btn btn-success" id="btn_send">Save
83+
</button>
84+
<button type="button" class="btn btn-primary" id="btn_send_test">Send Test
85+
</button>
86+
<div id="alert_mssage_alarm_config" style="display: none"
87+
class="alert alert-danger">
88+
<label>Oops! Please make some changes . (*) is required
89+
.</label>
90+
</div>
91+
<div id="success_mssage_alarm_config" style="display: none"
92+
class="alert alert-success">
93+
<label>Message sent success .</label>
94+
</div>
95+
</div>
96+
</div>
97+
<!-- /.col-lg-4 -->
98+
</div>
99+
<!-- /.row -->
100+
</div>
101+
<!-- /#page-wrapper -->
102+
</div>
103+
</div>
104+
</body>
105+
<jsp:include page="../public/script.jsp">
106+
<jsp:param value="plugins/select2/select2.min.js" name="loader" />
107+
<jsp:param value="main/alarm/config.js" name="loader" />
108+
</jsp:include>
109+
</html>

kafka-eagle-web/src/main/webapp/WEB-INF/views/public/navbar.jsp

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
data-toggle="dropdown"><i class="fa fa-sitemap"></i>
5757
${clusterAlias} </a></li>
5858
<li class="dropdown"><a href="#" class="dropdown-toggle"
59-
data-toggle="dropdown"><i class="fa fa-bookmark"></i> V1.3.9 </a></li>
59+
data-toggle="dropdown"><i class="fa fa-bookmark"></i> V1.4.0 </a></li>
6060
<li class="dropdown"><a href="#" class="dropdown-toggle"
6161
data-toggle="dropdown" aria-expanded="false"><i
6262
class="fa fa-user"></i> ${LOGIN_USER_SESSION.realname} <b
@@ -116,6 +116,8 @@
116116
class="fa fa-fw fa-bell"></i> Alarm <i
117117
class="fa fa-fw fa-caret-down"></i></a>
118118
<ul id="demo1" class="collapse">
119+
<li id="navbar_cli"><a href="/ke/alarm/config"><i
120+
class="fa fa-bullhorn fa-fw"></i> Config</a></li>
119121
<li><a href="#" data-toggle="collapse" data-target="#demo1_1"><i
120122
class="fa fa-fw fa-users"></i> Consumer <i
121123
class="fa fa-fw fa-caret-down"></i></a>

kafka-eagle-web/src/main/webapp/WEB-INF/views/topic/mock.jsp

+1-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@
6666
<div class="form-group">
6767
<label>Message (*)</label>
6868
<textarea id="ke_mock_content" name="ke_mock_content"
69-
class="form-control" placeholder="Limit 120 words." rows="3"
70-
maxlength="120"></textarea>
69+
class="form-control" placeholder="Send mock data" rows="10"></textarea>
7170
<label for="inputError" class="control-label text-danger"><i
7271
class="fa fa-info-circle"></i> Write something and send message
7372
to topic .</label>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
$(document).ready(function() {
2+
$("#select2val").select2({
3+
placeholder : "Alarm Type",
4+
ajax : {
5+
url : "/ke/alarm/type/list/ajax",
6+
dataType : 'json',
7+
delay : 250,
8+
data : function(params) {
9+
params.offset = 10;
10+
params.page = params.page || 1;
11+
return {
12+
name : params.term,
13+
page : params.page,
14+
offset : params.offset
15+
};
16+
},
17+
cache : true,
18+
processResults : function(data, params) {
19+
if (data.items.length > 0) {
20+
var datas = new Array();
21+
$.each(data.items, function(index, e) {
22+
console.log(e);
23+
var s = {};
24+
s.id = index + 1;
25+
s.text = e.text;
26+
datas[index] = s;
27+
});
28+
return {
29+
results : datas,
30+
pagination : {
31+
more : (params.page * params.offset) < data.total
32+
}
33+
};
34+
} else {
35+
return {
36+
results : []
37+
}
38+
}
39+
},
40+
escapeMarkup : function(markup) {
41+
return markup;
42+
},
43+
minimumInputLength : 1
44+
}
45+
});
46+
47+
$('#select2val').on('select2:select', function(evt) {
48+
var text = evt.params.data.text;
49+
$("#select2val").val(text);
50+
$("#ke_alarm_type").val(text);
51+
});
52+
});

pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
<groupId>org.smartloli.kafka.eagle</groupId>
66
<artifactId>kafka-eagle</artifactId>
77
<packaging>pom</packaging>
8-
<version>1.3.9</version>
8+
<version>1.4.0</version>
99
<name>ke</name>
1010
<url>http://central.maven.org/maven2/</url>
1111

1212
<properties>
13-
<project.version>1.3.9</project.version>
13+
<project.version>1.4.0</project.version>
1414
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
1515
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1616
</properties>

0 commit comments

Comments
 (0)