Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ops
/
monitor-ui
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
qinchao
7 years ago
Commit
ae84fc26c3cec3954f0661ebb9d9b78982c0ff77
1 parent
36431057
grafana提示告警发送到dingding
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
3 deletions
monitor-ui-ctrl/src/main/java/com/ui/ctrl/OuterIntfCtrl.java
monitor-ui-ctrl/src/main/java/com/ui/ctrl/OuterIntfCtrl.java
View file @
ae84fc2
...
...
@@ -146,6 +146,32 @@ public class OuterIntfCtrl {
/**
*
* Grafana alert webhook. refer to:http://docs.grafana.org/alerting/notifications/
*
* <pre>
*
* {
"title": "My alert",
"ruleId": 1,
"ruleName": "Load peaking!",
"ruleUrl": "http://url.to.grafana/db/dashboard/my_dashboard?panelId=2",
"state": "alerting",
"imageUrl": "http://s3.image.url",
"message": "Load is peaking. Make sure the traffic is real and spin up more webfronts",
"evalMatches": [
{
"metric": "requests",
"tags": {},
"value": 122
}
]
}
* </pre>
*
* Created by chunhua.zhang on 2017/5/26.
*/
/**
* 接口:grafana报警提示
* @param request
* @return
...
...
@@ -154,7 +180,7 @@ public class OuterIntfCtrl {
@ResponseBody
public
BaseResponse
grafanaWebHook
(
HttpServletRequest
request
)
{
try
{
String
jsonBody
=
IOUtils
.
toString
(
request
.
getInputStream
());
String
jsonBody
=
IOUtils
.
toString
(
request
.
getInputStream
()
,
"utf-8"
);
log
.
info
(
"receive grafana webhook message:{}"
,
jsonBody
);
JSONObject
alert
=
(
JSONObject
)
JSON
.
parse
(
jsonBody
);
String
title
=
""
;
...
...
@@ -164,8 +190,8 @@ public class OuterIntfCtrl {
if
(
alert
!=
null
){
title
=
alert
.
getString
(
"title"
);
state
=
alert
.
getString
(
"state"
);
imgUrl
=
alert
.
getString
(
"imageUrl"
);
message
=
alert
.
getString
(
"message"
);
imgUrl
=
alert
.
get
(
"imageUrl"
)==
null
?
""
:
alert
.
getString
(
"imageUrl"
);
message
=
alert
.
get
(
"message"
)==
null
?
""
:
alert
.
getString
(
"message"
);
}
Map
<
String
,
String
>
map
=
new
HashMap
<>();
...
...
Please
register
or
login
to post a comment