Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
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
wangpeng
dinky
Commits
0a332896
Unverified
Commit
0a332896
authored
Jul 24, 2023
by
ZackYoung
Committed by
GitHub
Jul 24, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize get metrics (#2145)
parent
beca02a7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
19 deletions
+28
-19
FlinkMetricsIndicator.java
...nky/configure/schedule/metrics/FlinkMetricsIndicator.java
+28
-19
No files found.
dinky-admin/src/main/java/org/dinky/configure/schedule/metrics/FlinkMetricsIndicator.java
View file @
0a332896
...
...
@@ -52,8 +52,10 @@ import org.springframework.stereotype.Component;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.thread.AsyncUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.URLUtil
;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.json.JSONArray
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
lombok.Getter
;
import
lombok.RequiredArgsConstructor
;
...
...
@@ -179,30 +181,37 @@ public class FlinkMetricsIndicator extends BaseSchedule {
return
;
}
// http://10.8.16.125:8282/jobs/06ccde3ff6e53bafe729e0e50fca72fd/vertices/cbc357ccb763df2852fee8c4fc7d55f2/metrics?get=0.buffers.inputExclusiveBuffersUsage
// http://10.8.16.125:8282/jobs/06ccde3ff6e53bafe729e0e50fca72fd/vertices/cbc357ccb763df2852fee8c4fc7d55f2/metrics?get=0.buffers.inputExclusiveBuffersUsage
,0.numRecordsInPerSecond
flinkMetrics
.
getVerticesAndMetricsMap
()
.
forEach
(
(
v
,
m
)
->
{
for
(
String
metrics
:
m
.
keySet
())
{
if
(
CollUtil
.
isEmpty
(
urlList
))
{
return
;
}
HttpUtils
.
asyncRequest
(
flinkMetrics
.
getUrls
(),
"/jobs/"
+
flinkMetrics
.
getJobId
()
+
"/vertices/"
+
v
+
"/metrics?get="
+
metrics
,
flinkMetricsRequestTimeout
.
get
(),
x
->
{
JSONArray
array
=
JSONUtil
.
parseArray
(
x
.
body
());
String
value
=
array
.
getJSONObject
(
0
).
getStr
(
"value"
);
m
.
put
(
metrics
,
value
);
});
if
(
CollUtil
.
isEmpty
(
urlList
))
{
return
;
}
String
metricsName
=
StrUtil
.
join
(
","
,
m
.
keySet
());
HttpUtils
.
asyncRequest
(
flinkMetrics
.
getUrls
(),
"/jobs/"
+
flinkMetrics
.
getJobId
()
+
"/vertices/"
+
v
+
"/metrics?get="
+
URLUtil
.
encode
(
metricsName
),
flinkMetricsRequestTimeout
.
get
(),
x
->
{
JSONArray
array
=
JSONUtil
.
parseArray
(
x
.
body
());
if
(
CollUtil
.
isEmpty
(
array
))
{
return
;
}
array
.
forEach
(
y
->
{
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
y
);
String
id
=
jsonObject
.
getStr
(
"id"
);
String
value
=
jsonObject
.
getStr
(
"value"
);
m
.
put
(
id
,
value
);
});
});
});
FLINK_METRICS_DATA_MAP
.
get
(
now
).
add
(
flinkMetrics
);
}
...
...
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