1
1
import React from 'react'
2
2
import { endOfToday , set } from 'date-fns'
3
- import TimeRange from 'react-timeline-range-slider'
3
+ import { TimePicker } from 'antd' ;
4
4
import { Collapse } from 'antd' ;
5
- import { RiseOutlined , FallOutlined } from '@ant-design/icons' ;
6
-
5
+ import { DownOutlined , FallOutlined , UpOutlined , WarningTwoTone } from '@ant-design/icons' ;
6
+ import { Select , Tag } from 'antd' ;
7
+ import moment from "moment" ;
8
+ const { Option } = Select ;
7
9
const { Panel } = Collapse ;
8
-
9
-
10
+ const Rise = < Tag icon = { < UpOutlined /> } color = "#2db7f5" > Shift Up</ Tag >
11
+ const Down = < Tag icon = { < DownOutlined /> } color = "#87d068" > Shift Down</ Tag >
12
+ const DownError = < > < Tag icon = { < DownOutlined /> } color = "#108ee9" > Spike Up</ Tag > < WarningTwoTone twoToneColor = "#f1c40f" /> </ >
10
13
const now = new Date ( )
11
14
const getTodayAtSpecificHour = ( hour = 12 ) =>
12
15
set ( now , { hours : hour , minutes : 0 , seconds : 0 , milliseconds : 0 } )
@@ -24,7 +27,7 @@ const disabledIntervals = [
24
27
]
25
28
26
29
27
- const MetricLine = ( { name, b, a , hits = undefined } ) => {
30
+ const MetricLine = ( { name, b, a , hits = undefined , rca = undefined } ) => {
28
31
return < div className = { "metric-line" } >
29
32
< div className = { "name" } > { name } </ div >
30
33
< div className = "baseline" >
@@ -39,6 +42,10 @@ const MetricLine = ({ name, b, a , hits = undefined}) => {
39
42
{ hits }
40
43
41
44
</ div >
45
+
46
+ < div className = "rca" >
47
+ { rca }
48
+ </ div >
42
49
</ div >
43
50
44
51
@@ -47,6 +54,7 @@ const MetricLine = ({ name, b, a , hits = undefined}) => {
47
54
export class Intelligence extends React . Component {
48
55
state = {
49
56
error : false ,
57
+ rcaId : "1" ,
50
58
selectedInterval : [ selectedStart , selectedEnd ] ,
51
59
}
52
60
@@ -55,7 +63,7 @@ export class Intelligence extends React.Component {
55
63
onChangeCallback = selectedInterval => this . setState ( { selectedInterval } )
56
64
57
65
render ( ) {
58
- const { selectedInterval , error } = this . state
66
+ const { rcaId , error } = this . state
59
67
const text = `
60
68
A dog is a type of domesticated animal.
61
69
Known for its loyalty and faithfulness,
@@ -64,35 +72,53 @@ export class Intelligence extends React.Component {
64
72
return (
65
73
< div className = "site-layout-background" style = { { padding : 8 , marginTop : 24 } } >
66
74
< div style = { { marginBottom :"10px" , fontSize : "16px" } } >
67
- RCA suggest: < span style = { { color : "red" } } > Network Latency</ span > , similar: 93.7%
75
+ < div style = { { display :"flex" } } >
76
+ < div style = { { flex : "1 1 800px" } } >
77
+ baseline: < TimePicker . RangePicker defaultValue = { [ moment ( '04:08:23' , 'HH:mm:ss' ) , moment ( '14:08:23' , 'HH:mm:ss' ) ] } size = "small" />
78
+ actual: < TimePicker . RangePicker defaultValue = { [ moment ( '14:08:24' , 'HH:mm:ss' ) , moment ( '14:19:23' , 'HH:mm:ss' ) ] } size = "small" />
79
+ </ div >
80
+ < div style = { { flex : "0 0 300px" } } >
81
+ rac:< Select defaultValue = "1" onChange = { id => { this . setState ( { rcaId : id } ) } } style = { { width : 220 } } value = { rcaId } >
82
+ < Option value = "1" > 97.1% 网络延迟</ Option >
83
+ < Option value = "2" > 14.3% CPU 异常负载</ Option >
84
+ < Option value = "3" > 4.7% Cpu 瓶颈</ Option >
85
+ < Option value = "4" > 3.2% 网络瓶颈</ Option >
86
+
87
+ </ Select >
88
+
89
+ </ div >
90
+ </ div >
91
+ { /*RCA suggest: <span style={{color: "red"}}>Network Latency</span>, similar: 93.7%*/ }
92
+
68
93
</ div >
69
- < TimeRange
70
- error = { error }
71
- ticksNumber = { 60 }
72
- selectedInterval = { selectedInterval }
73
- timelineInterval = { [ startTime , endTime ] }
74
- onUpdateCallback = { this . errorHandler }
75
- onChangeCallback = { this . onChangeCallback }
76
- disabledIntervals = { disabledIntervals }
77
- />
94
+ { /*<TimeRange*/ }
95
+ { /* error={error}*/ }
96
+ { /* ticksNumber={60}*/ }
97
+ { /* selectedInterval={selectedInterval}*/ }
98
+ { /* timelineInterval={[startTime, endTime]}*/ }
99
+ { /* onUpdateCallback={this.errorHandler}*/ }
100
+ { /* onChangeCallback={this.onChangeCallback}*/ }
101
+ { /* disabledIntervals={disabledIntervals}*/ }
102
+ { /*/>*/ }
103
+
78
104
79
105
80
106
< div className = { "metric-table" } style = { { padding : "0 16px" , marginTop : "36px" } } >
81
- < MetricLine name = { "" } b = { "baseline" } a = { "actual" } />
107
+ < MetricLine name = { "" } b = { "baseline" } a = { "actual" } rca = { "rca" } />
82
108
< MetricLine name = { "" } b = { "AVG" } a = { "AVG" } />
83
109
</ div >
84
110
< Collapse defaultActiveKey = { [ '1' , '2' ] } style = { { marginTop : "8px" } } >
85
111
< Panel header = "app:TiKV 172.31.34.23:20160" key = "1" >
86
112
< div className = { "metric-table" } >
87
- < MetricLine name = { "tikv.cpu.usage" } b = { "71.7%" } a = { "24.1%" } hits = { < > 2.9x< FallOutlined /> </ > } />
113
+ < MetricLine name = { "tikv.cpu.usage" } b = { "71.7%" } a = { "24.1%" } hits = { < > 2.9x< FallOutlined /> </ > } rca = { rcaId !== "1" ? DownError : Down } />
88
114
</ div >
89
115
</ Panel >
90
116
< Panel header = "app:TiDB 172.31.40.244:4000" key = "2" >
91
117
< div className = { "metric-table" } >
92
- < MetricLine name = { "tidb.duration.p99" } b = { "478ms" } a = { "1400ms" } />
93
- < MetricLine name = { "tidb.qps" } b = { "1170" } a = { "469" } />
94
- < MetricLine name = { "tidb.tps" } b = { "182" } a = { "68" } />
95
- < MetricLine name = { "tidb.tp_duration.p99" } b = { "2010ms" } a = { "3430ms" } />
118
+ < MetricLine name = { "tidb.duration.p99" } b = { "478ms" } a = { "1400ms" } rca = { Rise } />
119
+ < MetricLine name = { "tidb.qps" } b = { "1170" } a = { "469" } rca = { Down } />
120
+ < MetricLine name = { "tidb.tps" } b = { "182" } a = { "68" } rca = { Down } />
121
+ < MetricLine name = { "tidb.tp_duration.p99" } b = { "2010ms" } a = { "3430ms" } rca = { Rise } />
96
122
< Collapse defaultActiveKey = { [ '1' ] } style = { { marginTop : "8px" } } >
97
123
< Panel header = "Log Pattern Diff (power by naglfar)" key = "1" >
98
124
< div className = { "metric-table log" } >
0 commit comments