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
90ca6f0f
Unverified
Commit
90ca6f0f
authored
Jun 21, 2023
by
ZackYoung
Committed by
GitHub
Jun 21, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Optimize][monitor] Optimize flink metrics (#2100)
* optimize_flink_metrics * optimize_flink_metrics
parent
c65427cb
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
285 additions
and
224 deletions
+285
-224
MetricConfig.java
...admin/src/main/java/org/dinky/configure/MetricConfig.java
+7
-9
db-h2.sql
dinky-admin/src/main/resources/db/db-h2.sql
+14
-0
pom.xml
dinky-app/pom.xml
+1
-0
pom.xml
dinky-web-flink/pom.xml
+1
-0
data.tsx
dinky-web/src/pages/Metrics/Job/data.tsx
+1
-1
index.tsx
dinky-web/src/pages/Metrics/Server/CPU/index.tsx
+3
-3
index.tsx
dinky-web/src/pages/Metrics/Server/Heap/index.tsx
+23
-23
index.tsx
dinky-web/src/pages/Metrics/Server/OutHeap/index.tsx
+6
-6
index.tsx
dinky-web/src/pages/Metrics/Server/Thread/index.tsx
+5
-4
data.tsx
dinky-web/src/pages/Metrics/Server/data.tsx
+49
-27
index.tsx
dinky-web/src/pages/Metrics/Server/index.tsx
+29
-133
index.tsx
dinky-web/src/pages/Metrics/index.tsx
+146
-17
pom.xml
pom.xml
+0
-1
No files found.
dinky-admin/src/main/java/org/dinky/configure/MetricConfig.java
View file @
90ca6f0f
...
@@ -213,11 +213,11 @@ public class MetricConfig {
...
@@ -213,11 +213,11 @@ public class MetricConfig {
.
filter
(
x
->
x
.
getTaskId
().
equals
(
taskId
))
.
filter
(
x
->
x
.
getTaskId
().
equals
(
taskId
))
.
forEach
(
.
forEach
(
m
->
{
m
->
{
Map
<
String
,
List
<
String
>>
verticesAndMetricsMap
=
Map
<
String
,
Map
<
String
,
String
>>
verticesAndMetricsMap
=
flinkMetrics
.
getVerticesAndMetricsMap
();
flinkMetrics
.
getVerticesAndMetricsMap
();
verticesAndMetricsMap
.
putIfAbsent
(
verticesAndMetricsMap
.
putIfAbsent
(
m
.
getVertices
(),
new
ArrayList
<>());
m
.
getVertices
(),
new
ConcurrentHashMap
<>());
verticesAndMetricsMap
.
get
(
m
.
getVertices
()).
add
(
m
.
getMetrics
()
);
verticesAndMetricsMap
.
get
(
m
.
getVertices
()).
put
(
m
.
getMetrics
(),
""
);
});
});
for
(
History
jobHistory
:
historyList
)
{
for
(
History
jobHistory
:
historyList
)
{
if
(
jobInstance
.
getHistoryId
().
equals
(
jobHistory
.
getId
()))
{
if
(
jobInstance
.
getHistoryId
().
equals
(
jobHistory
.
getId
()))
{
...
@@ -251,7 +251,7 @@ public class MetricConfig {
...
@@ -251,7 +251,7 @@ public class MetricConfig {
.
getVerticesAndMetricsMap
()
.
getVerticesAndMetricsMap
()
.
forEach
(
.
forEach
(
(
v
,
m
)
->
{
(
v
,
m
)
->
{
for
(
String
metrics
:
m
)
{
for
(
String
metrics
:
m
.
keySet
()
)
{
if
(
CollUtil
.
isEmpty
(
urlList
))
{
if
(
CollUtil
.
isEmpty
(
urlList
))
{
return
;
return
;
}
}
...
@@ -266,9 +266,8 @@ public class MetricConfig {
...
@@ -266,9 +266,8 @@ public class MetricConfig {
REQUEST_FLINK_TIMEOUT
,
REQUEST_FLINK_TIMEOUT
,
x
->
{
x
->
{
JSONArray
array
=
JSONUtil
.
parseArray
(
x
.
body
());
JSONArray
array
=
JSONUtil
.
parseArray
(
x
.
body
());
String
key
=
v
+
metrics
;
String
value
=
array
.
getJSONObject
(
0
).
getStr
(
"value"
);
String
value
=
array
.
getJSONObject
(
0
).
getStr
(
"value"
);
flinkMetrics
.
getValueMap
().
put
(
key
,
value
);
m
.
put
(
metrics
,
value
);
});
});
}
}
});
});
...
@@ -285,8 +284,7 @@ public class MetricConfig {
...
@@ -285,8 +284,7 @@ public class MetricConfig {
private
String
jobId
;
private
String
jobId
;
private
Integer
taskId
;
private
Integer
taskId
;
private
List
<
String
>
urls
=
new
CopyOnWriteArrayList
<>();
private
List
<
String
>
urls
=
new
CopyOnWriteArrayList
<>();
private
Map
<
String
,
List
<
String
>>
verticesAndMetricsMap
=
new
HashMap
<>();
/** jobId -> metricsId -> metricsValue */
/** key为 vertices+metrics */
private
Map
<
String
,
Map
<
String
,
String
>>
verticesAndMetricsMap
=
new
HashMap
<>();
private
Map
<
String
,
String
>
valueMap
=
new
ConcurrentHashMap
<>();
}
}
}
}
dinky-admin/src/main/resources/db/db-h2.sql
View file @
90ca6f0f
...
@@ -1655,3 +1655,17 @@ VALUES (2, 1, 'python-udf', 'https://github.com/zackyoungh/dinky-quickstart-pyth
...
@@ -1655,3 +1655,17 @@ VALUES (2, 1, 'python-udf', 'https://github.com/zackyoungh/dinky-quickstart-pyth
,
NULL
,
NULL
,
NULL
,
NULL
,
''
,
NULL
,
NULL
,
NULL
,
NULL
,
''
,
2
,
1
,
NULL
,
NULL
,
0
,
2
,
1
,
NULL
,
NULL
,
0
,
0
,
1
,
'[]'
,
2
);
,
0
,
1
,
'[]'
,
2
);
CREATE
TABLE
`dinky_metrics`
(
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`task_id`
int
(
255
)
DEFAULT
NULL
,
`vertices`
varchar
(
255
)
DEFAULT
NULL
,
`metrics`
varchar
(
255
)
DEFAULT
NULL
,
`position`
int
(
11
)
DEFAULT
NULL
,
`show_type`
varchar
(
255
)
DEFAULT
NULL
,
`show_size`
varchar
(
255
)
DEFAULT
NULL
,
`title`
varchar
(
255
)
DEFAULT
NULL
,
`layout_name`
varchar
(
255
)
DEFAULT
NULL
,
`create_time`
datetime
DEFAULT
NULL
,
`update_time`
datetime
DEFAULT
NULL
)
ENGINE
=
InnoDB
;
dinky-app/pom.xml
View file @
90ca6f0f
...
@@ -38,6 +38,7 @@
...
@@ -38,6 +38,7 @@
<id>
web
</id>
<id>
web
</id>
<modules>
<modules>
<module>
../dlink-web
</module>
<module>
../dlink-web
</module>
<module>
../dinky-web-flink
</module>
</modules>
</modules>
</profile>
</profile>
</profiles>
</profiles>
...
...
dinky-web-flink/pom.xml
View file @
90ca6f0f
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
</parent>
</parent>
<artifactId>
dinky-web-flink
</artifactId>
<artifactId>
dinky-web-flink
</artifactId>
<name>
Dinky : Web : Flink
</name>
<properties>
<properties>
<maven.compiler.source>
8
</maven.compiler.source>
<maven.compiler.source>
8
</maven.compiler.source>
...
...
dinky-web/src/pages/Metrics/Job/data.tsx
View file @
90ca6f0f
...
@@ -51,7 +51,7 @@ export type SubTask = {
...
@@ -51,7 +51,7 @@ export type SubTask = {
export
type
ChartData
=
{
export
type
ChartData
=
{
time
:
Date
;
time
:
Date
;
value
:
number
;
value
:
number
|
string
;
}
}
...
...
dinky-web/src/pages/Metrics/Server/CPU/index.tsx
View file @
90ca6f0f
...
@@ -19,13 +19,13 @@
...
@@ -19,13 +19,13 @@
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
{
Area
,
AreaConfig
}
from
"@ant-design/plots"
;
import
{
Area
,
AreaConfig
}
from
"@ant-design/plots"
;
import
{
MetricsDataType
}
from
"@/pages/Metrics/Server/data"
;
import
{
JVMMetric
,
MetricsDataType
}
from
"@/pages/Metrics/Server/data"
;
import
{
Datum
}
from
"@antv/g2plot"
;
import
{
Datum
}
from
"@antv/g2plot"
;
import
{
AreaOptions
as
G2plotConfig
}
from
"@antv/g2plot/lib/plots/area/types"
;
import
{
AreaOptions
as
G2plotConfig
}
from
"@antv/g2plot/lib/plots/area/types"
;
type
CpuProps
=
{
type
CpuProps
=
{
data
:
MetricsDataType
[];
data
:
JVMMetric
[];
chartConfig
:
G2plotConfig
;
chartConfig
:
G2plotConfig
;
}
}
type
Cpu
=
{
type
Cpu
=
{
...
@@ -37,7 +37,7 @@ const CPU: React.FC<CpuProps> = (props) => {
...
@@ -37,7 +37,7 @@ const CPU: React.FC<CpuProps> = (props) => {
const
{
data
,
chartConfig
}
=
props
;
const
{
data
,
chartConfig
}
=
props
;
const
dataList
:
Cpu
[]
=
data
.
map
(
x
=>
{
const
dataList
:
Cpu
[]
=
data
.
map
(
x
=>
{
return
{
time
:
x
.
heartTime
,
value
:
Number
(
x
.
content
.
jvm
.
cpuUsed
.
toFixed
(
2
))};
return
{
time
:
x
.
time
,
value
:
Number
(
x
.
jvm
.
cpuUsed
.
toFixed
(
2
))};
})
})
...
...
dinky-web/src/pages/Metrics/Server/Heap/index.tsx
View file @
90ca6f0f
...
@@ -19,42 +19,42 @@
...
@@ -19,42 +19,42 @@
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
{
Area
,
AreaConfig
}
from
"@ant-design/plots"
;
import
{
Area
,
AreaConfig
}
from
"@ant-design/plots"
;
import
{
MetricsDataType
}
from
"@/pages/Metrics/Server/data"
;
import
{
JVMMetric
,
MetricsDataType
}
from
"@/pages/Metrics/Server/data"
;
import
{
Datum
}
from
"@antv/g2plot"
;
import
{
Datum
}
from
"@antv/g2plot"
;
import
{
AreaOptions
as
G2plotConfig
}
from
"@antv/g2plot/lib/plots/area/types"
;
import
{
AreaOptions
as
G2plotConfig
}
from
"@antv/g2plot/lib/plots/area/types"
;
type
HeapProps
=
{
type
HeapProps
=
{
data
:
MetricsDataType
[];
data
:
JVMMetric
[];
max
:
number
;
max
:
number
;
chartConfig
:
G2plotConfig
;
chartConfig
:
G2plotConfig
;
}
}
type
Heap
=
{
type
Heap
=
{
time
:
Date
;
time
:
Date
;
value
:
string
|
number
;
value
:
string
|
number
;
}
}
const
Heap
:
React
.
FC
<
HeapProps
>
=
(
props
)
=>
{
const
Heap
:
React
.
FC
<
HeapProps
>
=
(
props
)
=>
{
const
{
data
,
max
,
chartConfig
}
=
props
;
const
{
data
,
max
,
chartConfig
}
=
props
;
const
dataList
:
Heap
[]
=
data
.
map
(
x
=>
{
const
dataList
:
Heap
[]
=
data
.
map
(
x
=>
{
return
{
time
:
x
.
heartTime
,
value
:
Number
((
x
.
content
.
jvm
.
heapUsed
/
(
1024
*
1024
)).
toFixed
(
0
))};
return
{
time
:
x
.
time
,
value
:
parseInt
(
String
(
x
.
jvm
.
heapUsed
/
(
1024
*
1024
)))}
})
})
const
config
:
AreaConfig
=
{
const
config
:
AreaConfig
=
{
...
chartConfig
,
...
chartConfig
,
data
:
dataList
,
data
:
dataList
,
yAxis
:
{
yAxis
:
{
min
:
0
,
min
:
0
,
max
:
max
max
:
max
},
},
tooltip
:
{
tooltip
:
{
formatter
:
(
datum
:
Datum
)
=>
{
formatter
:
(
datum
:
Datum
)
=>
{
return
{
name
:
"Heap Memory"
,
value
:
datum
.
value
+
' MB'
};
return
{
name
:
"Heap Memory"
,
value
:
datum
.
value
+
' MB'
};
},
},
}
}
};
};
return
<
Area
{
...
config
}
/>;
return
<
Area
{
...
config
}
/>;
}
}
export
default
Heap
;
export
default
Heap
;
dinky-web/src/pages/Metrics/Server/OutHeap/index.tsx
View file @
90ca6f0f
...
@@ -17,25 +17,25 @@
...
@@ -17,25 +17,25 @@
*
*
*/
*/
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
React
from
"react"
;
import
{
Area
,
AreaConfig
}
from
"@ant-design/plots"
;
import
{
Area
,
AreaConfig
}
from
"@ant-design/plots"
;
import
{
MetricsDataType
}
from
"@/pages/Metrics/Server/data"
;
import
{
JVMMetric
}
from
"@/pages/Metrics/Server/data"
;
import
{
Datum
}
from
"@antv/g2plot"
;
import
{
Datum
}
from
"@antv/g2plot"
;
import
{
AreaOptions
as
G2plotConfig
}
from
"@antv/g2plot/lib/plots/area/types"
;
import
{
AreaOptions
as
G2plotConfig
}
from
"@antv/g2plot/lib/plots/area/types"
;
type
NonHeapProps
=
{
type
NonHeapProps
=
{
data
:
MetricsDataType
[];
data
:
JVMMetric
[];
max
:
number
;
max
:
number
;
chartConfig
:
G2plotConfig
;
chartConfig
:
G2plotConfig
;
}
}
type
NonHeap
=
{
type
NonHeap
=
{
time
:
Date
;
time
:
Date
;
value
:
string
|
number
;
value
:
number
;
}
}
const
NonHeap
:
React
.
FC
<
NonHeapProps
>
=
(
props
)
=>
{
const
NonHeap
:
React
.
FC
<
NonHeapProps
>
=
(
props
)
=>
{
const
{
data
,
max
,
chartConfig
}
=
props
;
const
{
data
,
max
,
chartConfig
}
=
props
;
const
dataList
:
NonHeap
[]
=
data
.
map
(
x
=>
{
const
dataList
:
NonHeap
[]
=
data
.
map
(
x
=>
{
return
{
time
:
x
.
heartTime
,
value
:
Number
((
x
.
content
.
jvm
.
nonHeapMax
/
(
1024
*
1024
)).
toFixed
(
0
))};
return
{
time
:
x
.
time
,
value
:
parseInt
(
String
(
x
.
jvm
.
nonHeapMax
/
(
1024
*
1024
)))}
})
})
...
...
dinky-web/src/pages/Metrics/Server/Thread/index.tsx
View file @
90ca6f0f
...
@@ -19,13 +19,13 @@
...
@@ -19,13 +19,13 @@
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
{
Area
,
AreaConfig
}
from
"@ant-design/plots"
;
import
{
Area
,
AreaConfig
}
from
"@ant-design/plots"
;
import
{
MetricsDataType
}
from
"@/pages/Metrics/Server/data"
;
import
{
JVMMetric
,
MetricsDataType
}
from
"@/pages/Metrics/Server/data"
;
import
Heap
from
"@/pages/Metrics/Server/Heap"
;
import
Heap
from
"@/pages/Metrics/Server/Heap"
;
import
{
AreaOptions
as
G2plotConfig
}
from
"@antv/g2plot/lib/plots/area/types"
;
import
{
AreaOptions
as
G2plotConfig
}
from
"@antv/g2plot/lib/plots/area/types"
;
import
{
Datum
}
from
"@antv/g2plot"
;
import
{
Datum
}
from
"@antv/g2plot"
;
type
ThreadProps
=
{
type
ThreadProps
=
{
data
:
MetricsDataType
[];
data
:
JVMMetric
[];
chartConfig
:
G2plotConfig
;
chartConfig
:
G2plotConfig
;
}
}
type
Thread
=
{
type
Thread
=
{
...
@@ -36,10 +36,11 @@ type Thread = {
...
@@ -36,10 +36,11 @@ type Thread = {
const
Thread
:
React
.
FC
<
ThreadProps
>
=
(
props
)
=>
{
const
Thread
:
React
.
FC
<
ThreadProps
>
=
(
props
)
=>
{
const
{
data
,
chartConfig
}
=
props
;
const
{
data
,
chartConfig
}
=
props
;
const
dataList
:
Thread
[]
=
data
.
map
(
x
=>
{
const
dataList
:
Thread
[]
=
data
.
map
(
x
=>
{
return
{
time
:
x
.
heartTime
,
value
:
x
.
content
.
jvm
.
threadPeakCount
,
name
:
"Peak"
};
return
{
time
:
x
.
time
,
value
:
x
.
jvm
.
threadPeakCount
,
name
:
"Peak"
};
})
})
const
dataList2
:
Thread
[]
=
data
.
map
(
x
=>
{
const
dataList2
:
Thread
[]
=
data
.
map
(
x
=>
{
return
{
time
:
x
.
heartTime
,
value
:
x
.
content
.
jvm
.
threadCount
,
name
:
"Count"
};
return
{
time
:
x
.
time
,
value
:
x
.
jvm
.
threadCount
,
name
:
"Count"
};
})
})
const
dataListAll
=
dataList
.
concat
(
dataList2
);
const
dataListAll
=
dataList
.
concat
(
dataList2
);
...
...
dinky-web/src/pages/Metrics/Server/data.tsx
View file @
90ca6f0f
...
@@ -18,39 +18,61 @@
...
@@ -18,39 +18,61 @@
*/
*/
export
type
MetricsDataType
=
{
export
type
MetricsDataType
=
{
content
:
{
// content: {
jvm
:
JVMType
,
// jvm: JVMType,
cpu
:
CPUType
,
// cpu: CPUType,
mem
:
MemoryType
,
// mem: MemoryType,
},
// },
metricsTotal
:
number
,
content
:
string
,
model
:
string
,
metricsTotal
:
number
,
heartTime
:
Date
,
model
:
string
,
heartTime
:
Date
,
}
export
type
JVMMetric
=
{
jvm
:
JVMType
,
cpu
:
CPUType
,
mem
:
MemoryType
,
time
:
Date
}
export
type
FlinkMetricsData
=
{
jobId
:
string
,
taskId
:
number
,
urls
:
string
[],
verticesAndMetricsMap
:
Record
<
string
,
Record
<
string
,
string
>>
}
export
type
JvmDataRecord
=
{
cpuLastValue
:
number
;
heapMax
:
number
;
heapLastValue
:
number
;
nonHeapMax
:
number
;
nonHeapLastValue
:
number
;
threadPeakCount
:
number
;
threadCount
:
number
;
}
}
type
JVMType
=
{
type
JVMType
=
{
total
:
number
,
total
:
number
,
max
:
number
,
max
:
number
,
free
:
number
,
free
:
number
,
cpuUsed
:
number
,
cpuUsed
:
number
,
nonHeapMax
:
number
,
nonHeapMax
:
number
,
nonHeapUsed
:
number
,
nonHeapUsed
:
number
,
heapMax
:
number
,
heapMax
:
number
,
heapUsed
:
number
,
heapUsed
:
number
,
threadPeakCount
:
number
,
threadPeakCount
:
number
,
threadCount
:
number
,
threadCount
:
number
,
version
:
string
,
version
:
string
,
home
:
string
,
home
:
string
,
}
}
type
CPUType
=
{
type
CPUType
=
{
cpuNum
:
number
,
cpuNum
:
number
,
sys
:
number
,
sys
:
number
,
wait
:
number
,
wait
:
number
,
free
:
number
,
free
:
number
,
}
}
type
MemoryType
=
{
type
MemoryType
=
{
total
:
number
,
total
:
number
,
used
:
number
,
used
:
number
,
free
:
number
,
free
:
number
,
}
}
dinky-web/src/pages/Metrics/Server/index.tsx
View file @
90ca6f0f
...
@@ -32,7 +32,7 @@ import {
...
@@ -32,7 +32,7 @@ import {
getSubMinTime
getSubMinTime
}
from
"@/pages/Metrics/Server/function"
;
}
from
"@/pages/Metrics/Server/function"
;
import
{
queryDataByParams
}
from
"@/services/BusinessCrud"
;
import
{
queryDataByParams
}
from
"@/services/BusinessCrud"
;
import
{
MetricsDataType
}
from
"@/pages/Metrics/Server/data"
;
import
{
JvmDataRecord
,
JVMMetric
,
MetricsDataType
}
from
"@/pages/Metrics/Server/data"
;
import
{
API_CONSTANTS
}
from
"@/services/constants"
;
import
{
API_CONSTANTS
}
from
"@/services/constants"
;
import
NonHeap
from
"@/pages/Metrics/Server/OutHeap"
;
import
NonHeap
from
"@/pages/Metrics/Server/OutHeap"
;
import
{
getSseData
}
from
"@/services/api"
;
import
{
getSseData
}
from
"@/services/api"
;
...
@@ -49,22 +49,15 @@ export const imgStyle = {
...
@@ -49,22 +49,15 @@ export const imgStyle = {
height
:
24
,
height
:
24
,
};
};
type
DataRecord
=
{
cpuLastValue
:
number
;
heapMax
:
number
;
heapLastValue
:
number
;
nonHeapMax
:
number
;
nonHeapLastValue
:
number
;
threadPeakCount
:
number
;
threadCount
:
number
;
}
type
ServerProp
=
{
type
ServerProp
=
{
chartConfig
:
G2plotConfig
;
chartConfig
:
G2plotConfig
data
:
JVMMetric
[]
}
}
const
Server
:
React
.
FC
<
ServerProp
>
=
(
props
)
=>
{
const
Server
:
React
.
FC
<
ServerProp
>
=
(
props
)
=>
{
const
{
chartConfig
}
=
props
const
{
chartConfig
,
data
}
=
props
const
commonConfig
:
G2plotConfig
=
{
const
commonConfig
:
G2plotConfig
=
{
...
chartConfig
,
...
chartConfig
,
yField
:
'value'
,
yField
:
'value'
,
...
@@ -74,116 +67,26 @@ const Server: React.FC<ServerProp> = (props) => {
...
@@ -74,116 +67,26 @@ const Server: React.FC<ServerProp> = (props) => {
mask
:
'HH:mm:ss'
,
mask
:
'HH:mm:ss'
,
}
}
}
}
const
jvmMetric
=
data
[
data
.
length
-
1
];
const
[
currentTime
,
setCurrentTime
]
=
useState
(
new
Date
());
const
showLastData
:
JvmDataRecord
=
jvmMetric
?{
const
[
dateRange
,
setDateRange
]
=
useState
<
string
>
(
'60s'
);
cpuLastValue
:
Number
(
jvmMetric
.
jvm
.
cpuUsed
.
toFixed
(
2
)),
const
[
startTime
,
setStartTime
]
=
useState
(
getSubMinTime
(
currentTime
,
1
));
heapMax
:
Number
((
jvmMetric
.
jvm
.
heapMax
/
(
1024
*
1024
)).
toFixed
(
0
)),
const
[
endTime
,
setEndTime
]
=
useState
(
new
Date
());
heapLastValue
:
Number
((
jvmMetric
.
jvm
.
heapUsed
/
(
1024
*
1024
)).
toFixed
(
0
)),
const
[
data
,
setData
]
=
useState
<
MetricsDataType
[]
>
([]);
nonHeapMax
:
Number
((
jvmMetric
.
jvm
.
nonHeapMax
/
(
1024
*
1024
)).
toFixed
(
0
)),
const
[
custom
,
setCustom
]
=
useState
<
boolean
>
(
false
);
nonHeapLastValue
:
Number
((
jvmMetric
.
jvm
.
nonHeapUsed
/
(
1024
*
1024
)).
toFixed
(
0
)),
threadPeakCount
:
jvmMetric
.
jvm
.
threadPeakCount
,
threadCount
:
jvmMetric
.
jvm
.
threadCount
,
const
[
dataRecord
,
setDataRecord
]
=
useState
<
DataRecord
>
({
}:{
heapLastValue
:
0
,
cpuLastValue
:
0
,
heapMax
:
0
cpuLastValue
:
0
,
,
threadCount
:
0
,
threadPeakCount
:
0
heapMax
:
0
,
,
nonHeapMax
:
0
,
nonHeapLastValue
:
0
heapLastValue
:
0
,
});
nonHeapMax
:
0
,
nonHeapLastValue
:
0
,
threadPeakCount
:
0
,
let
eventSource
:
EventSource
;
threadCount
:
0
,
const
getLastData
=
(
data
:
MetricsDataType
[])
=>
{
eventSource
=
getSseData
(
API_CONSTANTS
.
MONITOR_GET_LAST_DATA
+
"?lastTime="
+
endTime
.
getTime
());
eventSource
.
onmessage
=
e
=>
{
let
result
=
JSON
.
parse
(
e
.
data
);
if
(
result
.
model
!==
"local"
){
return
}
result
.
content
=
JSON
.
parse
(
result
.
content
)
data
.
push
(
result
)
setData
(
data
)
setDataRecord
({
cpuLastValue
:
result
.
content
.
jvm
.
cpuUsed
.
toFixed
(
2
),
heapMax
:
Number
((
result
.
content
.
jvm
.
heapMax
/
(
1024
*
1024
)).
toFixed
(
0
)),
heapLastValue
:
Number
((
result
.
content
.
jvm
.
heapUsed
/
(
1024
*
1024
)).
toFixed
(
0
)),
nonHeapMax
:
Number
((
result
.
content
.
jvm
.
nonHeapMax
/
(
1024
*
1024
)).
toFixed
(
0
)),
nonHeapLastValue
:
Number
((
result
.
content
.
jvm
.
nonHeapUsed
/
(
1024
*
1024
)).
toFixed
(
0
)),
threadPeakCount
:
result
.
content
.
jvm
.
threadPeakCount
,
threadCount
:
result
.
content
.
jvm
.
threadCount
,
})
}
}
const
getInitData
=
()
=>
{
queryDataByParams
(
API_CONSTANTS
.
MONITOR_GET_SYSTEM_DATA
,
{
startTime
:
startTime
.
getTime
(),
endTime
:
endTime
.
getTime
()
})
.
then
(
res
=>
{
(
res
as
any
[]).
forEach
(
x
=>
x
.
content
=
JSON
.
parse
(
x
.
content
))
res
=
(
res
as
MetricsDataType
[]).
filter
(
x
=>
x
.
model
==
"local"
)
if
(
!
custom
)
{
getLastData
(
res
)
}
else
{
setData
(
res
)
}
})
}
useEffect
(()
=>
{
const
timer
=
setInterval
(()
=>
{
setCurrentTime
(
new
Date
());
},
1000
);
getInitData
()
return
()
=>
{
clearInterval
(
timer
);
eventSource
?.
close
()
};
},
[
startTime
]);
const
handleDateRadioChange
=
(
e
:
any
)
=>
{
const
dateKey
=
e
.
target
.
value
;
setDateRange
(
dateKey
)
switch
(
dateKey
)
{
case
'60s'
:
setStartTime
(
getSubMinTime
(
currentTime
,
1
))
setEndTime
(
currentTime
)
break
;
case
'5min'
:
setStartTime
(
getSubMinTime
(
currentTime
,
5
))
setEndTime
(
currentTime
)
break
;
case
'10min'
:
setStartTime
(
getSubMinTime
(
currentTime
,
10
))
setEndTime
(
currentTime
)
break
;
case
'1h'
:
setStartTime
(
getSubMinTime
(
currentTime
,
60
))
setEndTime
(
currentTime
)
break
;
case
'2h'
:
setStartTime
(
getSubMinTime
(
currentTime
,
2
*
60
))
setEndTime
(
currentTime
)
break
;
case
'5h'
:
setStartTime
(
getSubMinTime
(
currentTime
,
5
*
60
))
setEndTime
(
currentTime
)
break
;
}
setCustom
(
false
)
}
const
handleRangeChange
=
(
dates
:
any
)
=>
{
setDateRange
(
'custom'
)
setStartTime
(
new
Date
(
dates
[
0
]))
setEndTime
(
new
Date
(
dates
[
1
]))
setCustom
(
true
)
}
}
const
extraDataBuilder
=
(
data
:
JvmDataRecord
)
=>
{
const
extraDataBuilder
=
(
data
:
DataRecord
)
=>
{
return
{
return
{
cpuLastValue
:
data
.
cpuLastValue
+
"%"
,
cpuLastValue
:
data
.
cpuLastValue
+
"%"
,
heapLastValue
:
data
.
heapLastValue
+
" / "
+
data
.
heapMax
+
" MB"
,
heapLastValue
:
data
.
heapLastValue
+
" / "
+
data
.
heapMax
+
" MB"
,
...
@@ -191,32 +94,25 @@ const Server: React.FC<ServerProp> = (props) => {
...
@@ -191,32 +94,25 @@ const Server: React.FC<ServerProp> = (props) => {
threadCount
:
data
.
threadCount
+
" / "
+
data
.
threadPeakCount
threadCount
:
data
.
threadCount
+
" / "
+
data
.
threadPeakCount
}
}
}
}
return
<>
return
<>
<
ProCard
size=
{
'small'
}
colSpan=
{
'100%'
}
bordered
>
<
GlobalFilter
custom=
{
custom
}
dateRange=
{
dateRange
}
endTime=
{
endTime
}
startTime=
{
startTime
}
handleDateRadioChange=
{
handleDateRadioChange
}
handleRangeChange=
{
handleRangeChange
}
/>
</
ProCard
>
<
ProCard
bordered
split=
{
'vertical'
}
>
<
ProCard
bordered
split=
{
'vertical'
}
>
<
ProCard
title=
{
<
Space
><
CPUIcon
style=
{
imgStyle
}
/>
CPU
</
Space
>
}
<
ProCard
title=
{
<
Space
><
CPUIcon
style=
{
imgStyle
}
/>
CPU
</
Space
>
}
extra=
{
extraDataBuilder
(
dataRecord
).
cpuLastValue
}
>
extra=
{
extraDataBuilder
(
showLastData
).
cpuLastValue
}
>
<
CPU
data=
{
data
}
chartConfig=
{
commonConfig
}
/>
<
CPU
data=
{
data
}
chartConfig=
{
commonConfig
}
/>
</
ProCard
>
</
ProCard
>
<
ProCard
title=
{
<
Space
><
HeapIcon
style=
{
imgStyle
}
/>
Heap
</
Space
>
}
<
ProCard
title=
{
<
Space
><
HeapIcon
style=
{
imgStyle
}
/>
Heap
</
Space
>
}
extra=
{
extraDataBuilder
(
dataRecord
).
heapLastValue
}
>
extra=
{
extraDataBuilder
(
showLastData
).
heapLastValue
}
>
<
Heap
data=
{
data
}
max=
{
dataRecord
.
heapMax
}
chartConfig=
{
commonConfig
}
/>
<
Heap
data=
{
data
}
max=
{
showLastData
.
heapMax
}
chartConfig=
{
commonConfig
}
/>
</
ProCard
>
</
ProCard
>
<
ProCard
title=
{
<
Space
><
ThreadIcon
style=
{
imgStyle
}
/>
Thread
</
Space
>
}
<
ProCard
title=
{
<
Space
><
ThreadIcon
style=
{
imgStyle
}
/>
Thread
</
Space
>
}
extra=
{
extraDataBuilder
(
dataRecord
).
threadCount
}
>
extra=
{
extraDataBuilder
(
showLastData
).
threadCount
}
>
<
Thread
data=
{
data
}
chartConfig=
{
commonConfig
}
/>
<
Thread
data=
{
data
}
chartConfig=
{
commonConfig
}
/>
</
ProCard
>
</
ProCard
>
<
ProCard
title=
{
<
Space
><
OutHeapIcon
style=
{
imgStyle
}
/>
Out Heap
</
Space
>
}
<
ProCard
title=
{
<
Space
><
OutHeapIcon
style=
{
imgStyle
}
/>
Out Heap
</
Space
>
}
extra=
{
extraDataBuilder
(
dataRecord
).
nonHeapLastValue
}
>
extra=
{
extraDataBuilder
(
showLastData
).
nonHeapLastValue
}
>
<
NonHeap
data=
{
data
}
max=
{
dataRecord
.
nonHeapMax
}
chartConfig=
{
commonConfig
}
/>
<
NonHeap
data=
{
data
}
max=
{
showLastData
.
nonHeapMax
}
chartConfig=
{
commonConfig
}
/>
</
ProCard
>
</
ProCard
>
</
ProCard
>
</
ProCard
>
</>
</>
}
}
export
default
Server
;
export
default
Server
;
dinky-web/src/pages/Metrics/index.tsx
View file @
90ca6f0f
...
@@ -23,10 +23,16 @@ import Server from "@/pages/Metrics/Server";
...
@@ -23,10 +23,16 @@ import Server from "@/pages/Metrics/Server";
import
{
PageContainer
,
ProCard
}
from
"@ant-design/pro-components"
;
import
{
PageContainer
,
ProCard
}
from
"@ant-design/pro-components"
;
import
Job
from
"./Job"
;
import
Job
from
"./Job"
;
import
{
AreaOptions
as
G2plotConfig
}
from
"@antv/g2plot/lib/plots/area/types"
;
import
{
AreaOptions
as
G2plotConfig
}
from
"@antv/g2plot/lib/plots/area/types"
;
import
{
Button
,
Input
}
from
"antd"
;
import
{
Button
,
Input
,
Row
}
from
"antd"
;
import
{
getMetricsLayout
}
from
"@/pages/Metrics/service"
;
import
{
getMetricsLayout
}
from
"@/pages/Metrics/service"
;
import
{
ChartData
,
MetricsLayout
}
from
"@/pages/Metrics/Job/data"
;
import
{
ChartData
,
MetricsLayout
}
from
"@/pages/Metrics/Job/data"
;
import
FlinkChart
from
"@/pages/Metrics/Job/FlinkChart"
;
import
FlinkChart
from
"@/pages/Metrics/Job/FlinkChart"
;
import
{
FlinkMetricsData
,
JvmDataRecord
,
JVMMetric
,
MetricsDataType
}
from
"@/pages/Metrics/Server/data"
;
import
{
getSseData
}
from
"@/services/api"
;
import
{
API_CONSTANTS
}
from
"@/services/constants"
;
import
{
queryDataByParams
}
from
"@/services/BusinessCrud"
;
import
GlobalFilter
from
"@/pages/Metrics/Server/GlobalFilter"
;
import
{
getSubMinTime
}
from
"@/pages/Metrics/Server/function"
;
const
commonChartConfig
:
G2plotConfig
=
{
const
commonChartConfig
:
G2plotConfig
=
{
data
:
[],
data
:
[],
...
@@ -36,30 +42,153 @@ const commonChartConfig: G2plotConfig = {
...
@@ -36,30 +42,153 @@ const commonChartConfig: G2plotConfig = {
}
}
export
default
()
=>
{
export
default
()
=>
{
const
[
layoutData
,
setLayoutData
]
=
useState
<
Record
<
string
,
MetricsLayout
[]
>>
();
const
[
layoutData
,
setLayoutData
]
=
useState
<
Record
<
string
,
MetricsLayout
[]
>>
();
const
[
chartDataList
,
setChartDataList
]
=
useState
<
Record
<
string
,
ChartData
[]
>>
();
const
[
jvmData
]
=
useState
<
JVMMetric
[]
>
([]);
const
[
flinkMetricsData
]
=
useState
<
FlinkMetricsData
[]
>
([]);
const
[
chartDataList
,
setChartDataList
]
=
useState
<
Record
<
string
,
ChartData
[]
>>
({});
const
[
eventSource
,
setEventSource
]
=
useState
<
EventSource
>
();
const
[
endTime
,
setEndTime
]
=
useState
(
new
Date
());
const
[
dateRange
,
setDateRange
]
=
useState
<
string
>
(
'60s'
);
const
[
custom
,
setCustom
]
=
useState
<
boolean
>
(
false
);
const
[
currentTime
,
setCurrentTime
]
=
useState
(
new
Date
());
const
[
startTime
,
setStartTime
]
=
useState
(
getSubMinTime
(
currentTime
,
1
));
const
[
dataRecord
,
setDataRecord
]
=
useState
<
JvmDataRecord
>
({
heapLastValue
:
0
,
cpuLastValue
:
0
,
heapMax
:
0
,
threadCount
:
0
,
threadPeakCount
:
0
,
nonHeapMax
:
0
,
nonHeapLastValue
:
0
});
useEffect
(()
=>
{
/**
const
getData
=
async
()
=>
{
* Data processing
setLayoutData
((
await
getMetricsLayout
()).
datas
)
* @param data
*/
const
dataProcess
=
(
data
:
MetricsDataType
)
=>
{
switch
(
data
.
model
)
{
case
"local"
:
const
d
=
JSON
.
parse
(
data
.
content
)
as
JVMMetric
;
d
.
time
=
data
.
heartTime
jvmData
.
push
(
d
)
break
case
"flink"
:
const
fd
=
JSON
.
parse
(
data
.
content
)
as
FlinkMetricsData
[];
fd
.
forEach
(
x
=>
{
const
verticesMap
=
x
.
verticesAndMetricsMap
;
Object
.
keys
(
verticesMap
).
forEach
(
y
=>
{
Object
.
keys
(
verticesMap
[
y
]).
forEach
(
m
=>
{
const
chartDataListElement
=
chartDataList
[
x
.
taskId
+
y
+
m
];
if
(
!
chartDataListElement
)
{
chartDataList
[
x
.
taskId
+
y
+
m
]
=
[]
}
chartDataList
[
x
.
taskId
+
y
+
m
].
push
({
time
:
data
.
heartTime
,
value
:
verticesMap
[
y
][
m
]})
})
})
})
break
}
}
getData
()
}
useEffect
(()
=>
{
const
timer
=
setInterval
(()
=>
{
setCurrentTime
(
new
Date
());
},
1000
);
getInitData
()
return
()
=>
{
clearInterval
(
timer
);
eventSource
?.
close
()
};
},
[
startTime
]);
useEffect
(()
=>
{
setEventSource
(
getSseData
(
API_CONSTANTS
.
MONITOR_GET_LAST_DATA
+
"?lastTime="
+
endTime
.
getTime
()))
},
[
endTime
])
useEffect
(()
=>
{
setLayout
()
},
[])
},
[])
useEffect
(()
=>
{
!
custom
&&
eventSource
&&
(
eventSource
.
onmessage
=
e
=>
{
let
result
=
JSON
.
parse
(
e
.
data
);
dataProcess
(
result
)
})
},
[
eventSource
,
custom
])
const
setLayout
=
async
()
=>
{
setLayoutData
((
await
getMetricsLayout
()).
datas
)
}
const
getInitData
=
()
=>
{
queryDataByParams
(
API_CONSTANTS
.
MONITOR_GET_SYSTEM_DATA
,
{
startTime
:
startTime
.
getTime
(),
endTime
:
endTime
.
getTime
()
})
.
then
(
res
=>
{
jvmData
.
length
=
0
;
flinkMetricsData
.
length
=
0
;
(
res
as
MetricsDataType
[]).
forEach
(
d
=>
dataProcess
(
d
))
})
}
const
handleRangeChange
=
(
dates
:
any
)
=>
{
setDateRange
(
'custom'
)
setStartTime
(
new
Date
(
dates
[
0
]))
setEndTime
(
new
Date
(
dates
[
1
]))
setCustom
(
true
)
}
const
handleDateRadioChange
=
(
e
:
any
)
=>
{
const
dateKey
=
e
.
target
.
value
;
setDateRange
(
dateKey
)
switch
(
dateKey
)
{
case
'60s'
:
setStartTime
(
getSubMinTime
(
currentTime
,
1
))
setEndTime
(
currentTime
)
break
;
case
'5min'
:
setStartTime
(
getSubMinTime
(
currentTime
,
5
))
setEndTime
(
currentTime
)
break
;
case
'10min'
:
setStartTime
(
getSubMinTime
(
currentTime
,
10
))
setEndTime
(
currentTime
)
break
;
case
'1h'
:
setStartTime
(
getSubMinTime
(
currentTime
,
60
))
setEndTime
(
currentTime
)
break
;
case
'2h'
:
setStartTime
(
getSubMinTime
(
currentTime
,
2
*
60
))
setEndTime
(
currentTime
)
break
;
case
'5h'
:
setStartTime
(
getSubMinTime
(
currentTime
,
5
*
60
))
setEndTime
(
currentTime
)
break
;
}
setCustom
(
false
)
}
return
<
PageContainer
title=
{
false
}
>
return
<
PageContainer
title=
{
false
}
>
<
ProCard
size=
{
'small'
}
colSpan=
{
'100%'
}
bordered
>
<
GlobalFilter
custom=
{
custom
}
dateRange=
{
dateRange
}
endTime=
{
endTime
}
startTime=
{
startTime
}
handleDateRadioChange=
{
handleDateRadioChange
}
handleRangeChange=
{
handleRangeChange
}
/>
</
ProCard
>
<
ProCard
collapsible
title=
{
'Dinky Server'
}
ghost
hoverable
bordered
headerBordered
>
<
ProCard
collapsible
title=
{
'Dinky Server'
}
ghost
hoverable
bordered
headerBordered
>
<
Server
chartConfig=
{
commonChartConfig
}
/>
<
Server
chartConfig=
{
commonChartConfig
}
data=
{
jvmData
}
/>
</
ProCard
>
</
ProCard
>
{
(
layoutData
!=
undefined
)
&&
Object
.
keys
(
layoutData
).
map
(
name
=>
{
{
(
layoutData
!=
undefined
)
&&
Object
.
keys
(
layoutData
).
map
(
name
=>
{
return
<
ProCard
collapsible
title=
{
name
}
ghost
hoverable
bordered
headerBordered
>
return
<
ProCard
collapsible
title=
{
name
}
ghost
hoverable
bordered
headerBordered
gutter=
{
[
0
,
8
]
}
>
{
layoutData
[
name
].
map
(
j
=>
{
<
Row
gutter=
{
[
8
,
16
]
}
>
return
<></>
{
layoutData
[
name
].
map
(
j
=>
{
// return <FlinkChart chartSize=
{
j
.
showSize
}
chartType
=
{
j
.
showType
}
// return <></>
// onChangeJobState=
{(
chartSize
,
chartType
)
=>
{
return
<
FlinkChart
chartSize=
{
j
.
showSize
}
chartType=
{
j
.
showType
}
// j.showSize=chartSize
onChangeJobState=
{
(
chartSize
,
chartType
)
=>
{
// j.showType=chartType
j
.
showSize
=
chartSize
//
}}
j
.
showType
=
chartType
// layoutData=
{
chartData
[
j
.
taskId
+
j
.
subTaskId
+
j
.
metrics
]}
title
=
{
j
.
metrics
}
/
>
}
}
})
}
data=
{
chartDataList
[
j
.
taskId
+
j
.
vertices
+
j
.
metrics
]
}
title=
{
j
.
metrics
}
/>
})
}
</
Row
>
</
ProCard
>
</
ProCard
>
})
}
})
}
...
...
pom.xml
View file @
90ca6f0f
...
@@ -48,7 +48,6 @@
...
@@ -48,7 +48,6 @@
<module>
dinky-app
</module>
<module>
dinky-app
</module>
<module>
dinky-admin
</module>
<module>
dinky-admin
</module>
<module>
dinky-assembly
</module>
<module>
dinky-assembly
</module>
<module>
dinky-web-flink
</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