Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dlink
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhaowei
dlink
Commits
54340813
Commit
54340813
authored
Mar 07, 2022
by
wenmo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实时监控和自动告警
parent
beeb8a51
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
125 additions
and
38 deletions
+125
-38
README.md
README.md
+2
-0
FlinkJobTask.java
dlink-admin/src/main/java/com/dlink/job/FlinkJobTask.java
+1
-3
TaskServiceImpl.java
...src/main/java/com/dlink/service/impl/TaskServiceImpl.java
+14
-5
AlertMsg.java
...nk-alert-base/src/main/java/com/dlink/alert/AlertMsg.java
+76
-0
DingTalkConstants.java
...main/java/com/dlink/alert/dingtalk/DingTalkConstants.java
+12
-12
WeChatAlert.java
...hat/src/main/java/com/dlink/alert/wechat/WeChatAlert.java
+2
-1
WeChatConstants.java
...src/main/java/com/dlink/alert/wechat/WeChatConstants.java
+1
-1
WeChatSender.java
...at/src/main/java/com/dlink/alert/wechat/WeChatSender.java
+2
-3
DaemonFactory.java
...on/src/main/java/com/dlink/daemon/task/DaemonFactory.java
+1
-4
DaemonTask.java
...aemon/src/main/java/com/dlink/daemon/task/DaemonTask.java
+5
-5
DingTalkForm.tsx
...k-web/src/pages/AlertInstance/components/DingTalkForm.tsx
+1
-1
Welcome.tsx
dlink-web/src/pages/Welcome.tsx
+6
-0
pom.xml
pom.xml
+2
-3
No files found.
README.md
View file @
54340813
...
@@ -87,6 +87,8 @@ Dinky(原 Dlink):
...
@@ -87,6 +87,8 @@ Dinky(原 Dlink):
| | 归档 | 新增 执行与提交历史 | 0.4.0 |
| | 归档 | 新增 执行与提交历史 | 0.4.0 |
| 运维中心 | 主页 | 新增 任务实例列表 | 0.6.0 |
| 运维中心 | 主页 | 新增 任务实例列表 | 0.6.0 |
| | 作业监控 | 新增 作业总览 | 0.6.0 |
| | 作业监控 | 新增 作业总览 | 0.6.0 |
| | | 新增 实时监控 Flink Job | 0.6.0 |
| | | 新增 自动告警 | 0.6.0 |
| | | 新增 FlinkWebUI 跳转 | 0.6.0 |
| | | 新增 FlinkWebUI 跳转 | 0.6.0 |
| | | 新增 智能重启(重新上线) | 0.6.0 |
| | | 新增 智能重启(重新上线) | 0.6.0 |
| | | 新增 智能停止(下线) | 0.6.0 |
| | | 新增 智能停止(下线) | 0.6.0 |
...
...
dlink-admin/src/main/java/com/dlink/job/FlinkJobTask.java
View file @
54340813
...
@@ -49,10 +49,8 @@ public class FlinkJobTask implements DaemonTask {
...
@@ -49,10 +49,8 @@ public class FlinkJobTask implements DaemonTask {
}
}
preDealTime
=
System
.
currentTimeMillis
();
preDealTime
=
System
.
currentTimeMillis
();
JobInstance
jobInstance
=
taskService
.
refreshJobInstance
(
config
.
getId
());
JobInstance
jobInstance
=
taskService
.
refreshJobInstance
(
config
.
getId
());
log
.
info
(
"监控任务:"
+
jobInstance
.
getId
());
if
(!
JobStatus
.
isDone
(
jobInstance
.
getStatus
())){
if
(!
JobStatus
.
isDone
(
jobInstance
.
getStatus
())){
DefaultThreadPool
.
getInstance
().
execute
(
this
);
DefaultThreadPool
.
getInstance
().
execute
(
this
);
};
}
}
}
}
}
dlink-admin/src/main/java/com/dlink/service/impl/TaskServiceImpl.java
View file @
54340813
...
@@ -3,6 +3,7 @@ package com.dlink.service.impl;
...
@@ -3,6 +3,7 @@ package com.dlink.service.impl;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.dlink.alert.Alert
;
import
com.dlink.alert.Alert
;
import
com.dlink.alert.AlertConfig
;
import
com.dlink.alert.AlertConfig
;
import
com.dlink.alert.AlertMsg
;
import
com.dlink.alert.AlertResult
;
import
com.dlink.alert.AlertResult
;
import
com.dlink.assertion.Assert
;
import
com.dlink.assertion.Assert
;
import
com.dlink.assertion.Asserts
;
import
com.dlink.assertion.Asserts
;
...
@@ -17,11 +18,9 @@ import com.dlink.gateway.config.SavePointStrategy;
...
@@ -17,11 +18,9 @@ import com.dlink.gateway.config.SavePointStrategy;
import
com.dlink.gateway.config.SavePointType
;
import
com.dlink.gateway.config.SavePointType
;
import
com.dlink.gateway.model.JobInfo
;
import
com.dlink.gateway.model.JobInfo
;
import
com.dlink.gateway.result.SavePointResult
;
import
com.dlink.gateway.result.SavePointResult
;
import
com.dlink.interceptor.FlinkInterceptor
;
import
com.dlink.job.JobConfig
;
import
com.dlink.job.JobConfig
;
import
com.dlink.job.JobManager
;
import
com.dlink.job.JobManager
;
import
com.dlink.job.JobResult
;
import
com.dlink.job.JobResult
;
import
com.dlink.mapper.JobInstanceMapper
;
import
com.dlink.mapper.TaskMapper
;
import
com.dlink.mapper.TaskMapper
;
import
com.dlink.metadata.driver.Driver
;
import
com.dlink.metadata.driver.Driver
;
import
com.dlink.metadata.result.JdbcSelectResult
;
import
com.dlink.metadata.result.JdbcSelectResult
;
...
@@ -34,6 +33,7 @@ import org.springframework.beans.factory.annotation.Value;
...
@@ -34,6 +33,7 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -454,18 +454,27 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
...
@@ -454,18 +454,27 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
if
(
Asserts
.
isNotNull
(
task
.
getAlertGroupId
())){
if
(
Asserts
.
isNotNull
(
task
.
getAlertGroupId
())){
AlertGroup
alertGroup
=
alertGroupService
.
getAlertGroupInfo
(
task
.
getAlertGroupId
());
AlertGroup
alertGroup
=
alertGroupService
.
getAlertGroupInfo
(
task
.
getAlertGroupId
());
if
(
Asserts
.
isNotNull
(
alertGroup
)){
if
(
Asserts
.
isNotNull
(
alertGroup
)){
List
<
AlertMsg
>
alertMsgList
=
new
ArrayList
<>();
AlertMsg
alertMsg
=
new
AlertMsg
();
alertMsg
.
setType
(
"Flink 实时监控"
);
alertMsg
.
setTime
(
LocalDateTime
.
now
().
toString
());
alertMsg
.
setId
(
jobInstance
.
getId
().
toString
());
alertMsg
.
setName
(
task
.
getAlias
());
alertMsg
.
setStatus
(
jobInstance
.
getStatus
());
alertMsg
.
setContent
(
jobInstance
.
getJid
());
alertMsgList
.
add
(
alertMsg
);
for
(
AlertInstance
alertInstance:
alertGroup
.
getInstances
()){
for
(
AlertInstance
alertInstance:
alertGroup
.
getInstances
()){
sendAlert
(
alertInstance
,
jobInstance
,
task
);
sendAlert
(
alertInstance
,
jobInstance
,
task
,
alertMsgList
);
}
}
}
}
}
}
}
}
private
void
sendAlert
(
AlertInstance
alertInstance
,
JobInstance
jobInstance
,
Task
task
){
private
void
sendAlert
(
AlertInstance
alertInstance
,
JobInstance
jobInstance
,
Task
task
,
List
<
AlertMsg
>
alertMsgList
){
AlertConfig
alertConfig
=
AlertConfig
.
build
(
alertInstance
.
getName
(),
alertInstance
.
getType
(),
JSONUtil
.
toMap
(
alertInstance
.
getParams
()));
AlertConfig
alertConfig
=
AlertConfig
.
build
(
alertInstance
.
getName
(),
alertInstance
.
getType
(),
JSONUtil
.
toMap
(
alertInstance
.
getParams
()));
Alert
alert
=
Alert
.
build
(
alertConfig
);
Alert
alert
=
Alert
.
build
(
alertConfig
);
String
title
=
"任务【"
+
task
.
getAlias
()+
"】:"
+
jobInstance
.
getStatus
();
String
title
=
"任务【"
+
task
.
getAlias
()+
"】:"
+
jobInstance
.
getStatus
();
String
content
=
"jid【"
+
jobInstance
.
getJid
()+
"】于【"
+
jobInstance
.
getUpdateTime
().
toString
()+
"】时【"
+
jobInstance
.
getStatus
()+
"】!"
;
String
content
=
JSONUtil
.
toJsonString
(
alertMsgList
)
;
AlertResult
alertResult
=
alert
.
send
(
title
,
content
);
AlertResult
alertResult
=
alert
.
send
(
title
,
content
);
AlertHistory
alertHistory
=
new
AlertHistory
();
AlertHistory
alertHistory
=
new
AlertHistory
();
alertHistory
.
setAlertGroupId
(
task
.
getAlertGroupId
());
alertHistory
.
setAlertGroupId
(
task
.
getAlertGroupId
());
...
...
dlink-alert/dlink-alert-base/src/main/java/com/dlink/alert/AlertMsg.java
0 → 100644
View file @
54340813
package
com
.
dlink
.
alert
;
/**
* AlertMsg
*
* @author wenmo
* @since 2022/3/7 18:30
**/
public
class
AlertMsg
{
private
String
type
;
private
String
time
;
private
String
id
;
private
String
name
;
private
String
status
;
private
String
content
;
public
AlertMsg
()
{
}
public
AlertMsg
(
String
type
,
String
time
,
String
id
,
String
name
,
String
status
,
String
content
)
{
this
.
type
=
type
;
this
.
time
=
time
;
this
.
id
=
id
;
this
.
name
=
name
;
this
.
status
=
status
;
this
.
content
=
content
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
String
getTime
()
{
return
time
;
}
public
void
setTime
(
String
time
)
{
this
.
time
=
time
;
}
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
String
getContent
()
{
return
content
;
}
public
void
setContent
(
String
content
)
{
this
.
content
=
content
;
}
}
dlink-alert/dlink-alert-dingtalk/src/main/java/com/dlink/alert/dingtalk/DingTalkConstants.java
View file @
54340813
...
@@ -10,29 +10,29 @@ public final class DingTalkConstants {
...
@@ -10,29 +10,29 @@ public final class DingTalkConstants {
static
final
String
TYPE
=
"DingTalk"
;
static
final
String
TYPE
=
"DingTalk"
;
static
final
String
PROXY_ENABLE
=
"
I
sEnableProxy"
;
static
final
String
PROXY_ENABLE
=
"
i
sEnableProxy"
;
static
final
String
WEB_HOOK
=
"
WebH
ook"
;
static
final
String
WEB_HOOK
=
"
webh
ook"
;
static
final
String
KEYWORD
=
"
K
eyword"
;
static
final
String
KEYWORD
=
"
k
eyword"
;
static
final
String
SECRET
=
"
S
ecret"
;
static
final
String
SECRET
=
"
s
ecret"
;
static
final
String
MSG_TYPE
=
"
M
sgType"
;
static
final
String
MSG_TYPE
=
"
m
sgType"
;
static
final
String
AT_MOBILES
=
"
A
tMobiles"
;
static
final
String
AT_MOBILES
=
"
a
tMobiles"
;
static
final
String
AT_USERIDS
=
"
A
tUserIds"
;
static
final
String
AT_USERIDS
=
"
a
tUserIds"
;
static
final
String
AT_ALL
=
"
I
sAtAll"
;
static
final
String
AT_ALL
=
"
i
sAtAll"
;
static
final
String
PROXY
=
"
P
roxy"
;
static
final
String
PROXY
=
"
p
roxy"
;
static
final
String
PORT
=
"
P
ort"
;
static
final
String
PORT
=
"
p
ort"
;
static
final
String
USER
=
"
U
ser"
;
static
final
String
USER
=
"
u
ser"
;
static
final
String
PASSWORD
=
"
P
assword"
;
static
final
String
PASSWORD
=
"
p
assword"
;
static
final
String
MSG_TYPE_TEXT
=
"text"
;
static
final
String
MSG_TYPE_TEXT
=
"text"
;
...
...
dlink-alert/dlink-alert-wechat/src/main/java/com/dlink/alert/wechat/WeChatAlert.java
View file @
54340813
...
@@ -17,6 +17,7 @@ public class WeChatAlert extends AbstractAlert {
...
@@ -17,6 +17,7 @@ public class WeChatAlert extends AbstractAlert {
@Override
@Override
public
AlertResult
send
(
String
title
,
String
content
)
{
public
AlertResult
send
(
String
title
,
String
content
)
{
return
null
;
WeChatSender
sender
=
new
WeChatSender
(
getConfig
().
getParam
());
return
sender
.
send
(
title
,
content
);
}
}
}
}
dlink-alert/dlink-alert-wechat/src/main/java/com/dlink/alert/wechat/WeChatConstants.java
View file @
54340813
...
@@ -28,7 +28,7 @@ public class WeChatConstants {
...
@@ -28,7 +28,7 @@ public class WeChatConstants {
static
final
String
TEAM_SEND_MSG
=
"teamSendMsg"
;
static
final
String
TEAM_SEND_MSG
=
"teamSendMsg"
;
static
final
String
USER_SEND_MSG
=
"
userSendMsg
"
;
static
final
String
USER_SEND_MSG
=
"
{\"touser\":\"{toUser}\",\"agentid\":{agentId},\"msgtype\":\"{showType}\",\"{showType}\":{\"content\":\"{msg}\"}}
"
;
static
final
String
AGENT_ID
=
"agentId"
;
static
final
String
AGENT_ID
=
"agentId"
;
...
...
dlink-alert/dlink-alert-wechat/src/main/java/com/dlink/alert/wechat/WeChatSender.java
View file @
54340813
...
@@ -52,7 +52,7 @@ public class WeChatSender {
...
@@ -52,7 +52,7 @@ public class WeChatSender {
String
weChatCorpId
=
config
.
get
(
WeChatConstants
.
CORP_ID
);
String
weChatCorpId
=
config
.
get
(
WeChatConstants
.
CORP_ID
);
String
weChatSecret
=
config
.
get
(
WeChatConstants
.
SECRET
);
String
weChatSecret
=
config
.
get
(
WeChatConstants
.
SECRET
);
String
weChatTokenUrl
=
WeChatConstants
.
TOKEN_URL
;
String
weChatTokenUrl
=
WeChatConstants
.
TOKEN_URL
;
weChatUserSendMsg
=
config
.
get
(
WeChatConstants
.
USER_SEND_MSG
)
;
weChatUserSendMsg
=
WeChatConstants
.
USER_SEND_MSG
;
sendType
=
config
.
get
(
WeChatConstants
.
SEND_TYPE
);
sendType
=
config
.
get
(
WeChatConstants
.
SEND_TYPE
);
showType
=
config
.
get
(
WeChatConstants
.
SHOW_TYPE
);
showType
=
config
.
get
(
WeChatConstants
.
SHOW_TYPE
);
requireNonNull
(
showType
,
WeChatConstants
.
SHOW_TYPE
+
" must not null"
);
requireNonNull
(
showType
,
WeChatConstants
.
SHOW_TYPE
+
" must not null"
);
...
@@ -107,8 +107,7 @@ public class WeChatSender {
...
@@ -107,8 +107,7 @@ public class WeChatSender {
}
finally
{
}
finally
{
response
.
close
();
response
.
close
();
}
}
logger
.
info
(
"Enterprise WeChat send [{}], param:{}, resp:{}"
,
// logger.info("Enterprise WeChat send [{}], param:{}, resp:{}", url, data, resp);
url
,
data
,
resp
);
return
resp
;
return
resp
;
}
}
}
}
...
...
dlink-daemon/src/main/java/com/dlink/daemon/task/DaemonFactory.java
View file @
54340813
...
@@ -2,12 +2,10 @@ package com.dlink.daemon.task;
...
@@ -2,12 +2,10 @@ package com.dlink.daemon.task;
import
com.dlink.daemon.constant.FlinkTaskConstant
;
import
com.dlink.daemon.constant.FlinkTaskConstant
;
import
com.dlink.daemon.pool.DefaultThreadPool
;
import
com.dlink.daemon.pool.DefaultThreadPool
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.List
;
import
java.util.List
;
public
class
DaemonFactory
{
public
class
DaemonFactory
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
DaemonFactory
.
class
);
public
static
void
start
(
List
<
DaemonTaskConfig
>
configList
){
public
static
void
start
(
List
<
DaemonTaskConfig
>
configList
){
Thread
thread
=
new
Thread
(()
->
{
Thread
thread
=
new
Thread
(()
->
{
...
@@ -30,7 +28,6 @@ public class DaemonFactory {
...
@@ -30,7 +28,6 @@ public class DaemonFactory {
}
else
if
(
defaultThreadPool
.
getWorkCount
()
>
num
)
{
}
else
if
(
defaultThreadPool
.
getWorkCount
()
>
num
)
{
defaultThreadPool
.
removeWorker
(
defaultThreadPool
.
getWorkCount
()
-
num
);
defaultThreadPool
.
removeWorker
(
defaultThreadPool
.
getWorkCount
()
-
num
);
}
}
log
.
info
(
" >>> taskSize:"
+
taskSize
+
" workCount: "
+
defaultThreadPool
.
getWorkCount
());
}
}
});
});
thread
.
start
();
thread
.
start
();
...
...
dlink-daemon/src/main/java/com/dlink/daemon/task/DaemonTask.java
View file @
54340813
...
@@ -21,11 +21,11 @@ public interface DaemonTask {
...
@@ -21,11 +21,11 @@ public interface DaemonTask {
}
}
static
DaemonTask
build
(
DaemonTaskConfig
config
)
{
static
DaemonTask
build
(
DaemonTaskConfig
config
)
{
Optional
<
DaemonTask
>
optionalD
river
=
DaemonTask
.
get
(
config
);
Optional
<
DaemonTask
>
optionalD
aemonTask
=
DaemonTask
.
get
(
config
);
if
(!
optionalD
river
.
isPresent
())
{
if
(!
optionalD
aemonTask
.
isPresent
())
{
throw
new
DaemonTaskException
(
"不支持线程任务类型【"
+
config
.
getType
()
+
"】"
);
throw
new
DaemonTaskException
(
"不支持线程任务类型【"
+
config
.
getType
()
+
"】"
);
}
}
DaemonTask
daemonTask
=
optionalD
river
.
get
();
DaemonTask
daemonTask
=
optionalD
aemonTask
.
get
();
return
daemonTask
;
return
daemonTask
;
}
}
...
...
dlink-web/src/pages/AlertInstance/components/DingTalkForm.tsx
View file @
54340813
...
@@ -106,7 +106,7 @@ const DingTalkForm: React.FC<AlertInstanceFormProps> = (props) => {
...
@@ -106,7 +106,7 @@ const DingTalkForm: React.FC<AlertInstanceFormProps> = (props) => {
</
Form
.
Item
></>:
undefined
</
Form
.
Item
></>:
undefined
}
}
<
Form
.
Item
<
Form
.
Item
name=
"
I
sAtAll"
name=
"
i
sAtAll"
label=
"@所有人"
>
label=
"@所有人"
>
<
Switch
checkedChildren=
"启用"
unCheckedChildren=
"禁用"
<
Switch
checkedChildren=
"启用"
unCheckedChildren=
"禁用"
defaultChecked=
{
formVals
.
IsAtAll
}
/>
defaultChecked=
{
formVals
.
IsAtAll
}
/>
...
...
dlink-web/src/pages/Welcome.tsx
View file @
54340813
...
@@ -701,6 +701,12 @@ export default (): React.ReactNode => {
...
@@ -701,6 +701,12 @@ export default (): React.ReactNode => {
<
li
>
<
li
>
<
Link
>
新增 运维中心任务监控的智能重启和报警推送
</
Link
>
<
Link
>
新增 运维中心任务监控的智能重启和报警推送
</
Link
>
</
li
>
</
li
>
<
li
>
<
Link
>
新增 实时监控 Flink Job
</
Link
>
</
li
>
<
li
>
<
Link
>
新增 实时自动告警
</
Link
>
</
li
>
</
ul
>
</
ul
>
</
Paragraph
>
</
Paragraph
>
</
Timeline
.
Item
>
</
Timeline
.
Item
>
...
...
pom.xml
View file @
54340813
...
@@ -18,14 +18,13 @@
...
@@ -18,14 +18,13 @@
<module>
dlink-connectors
</module>
<module>
dlink-connectors
</module>
<module>
dlink-executor
</module>
<module>
dlink-executor
</module>
<module>
dlink-extends
</module>
<module>
dlink-extends
</module>
<module>
dlink-alert
</module>
<module>
dlink-daemon
</module>
<module>
dlink-core
</module>
<module>
dlink-core
</module>
<module>
dlink-app
</module>
<module>
dlink-app
</module>
<module>
dlink-web
</module>
<module>
dlink-web
</module>
<module>
dlink-admin
</module>
<module>
dlink-admin
</module>
<module>
dlink-assembly
</module>
<module>
dlink-assembly
</module>
<module>
dlink-alert
</module>
<module>
dlink-daemon
</module>
</modules>
</modules>
<properties>
<properties>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment