/
context.ts
78 lines (64 loc) · 1.9 KB
/
context.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import {
IOverviewDataSource,
IOverviewContext,
ReqConfig
} from '@pingcap/tidb-dashboard-lib'
import client from '~/client'
import { overviewMetrics } from './metricsQueries'
class DataSource implements IOverviewDataSource {
getTiDBTopology(options?: ReqConfig) {
return client.getInstance().getTiDBTopology(options)
}
getStoreTopology(options?: ReqConfig) {
return client.getInstance().getStoreTopology(options)
}
getPDTopology(options?: ReqConfig) {
return client.getInstance().getPDTopology(options)
}
getTiCDCTopology(options?: ReqConfig) {
return client.getInstance().getTiCDCTopology(options)
}
getTiProxyTopology(options?: ReqConfig) {
return client.getInstance().getTiProxyTopology(options)
}
getTSOTopology(options?: ReqConfig) {
return client.getInstance().getTSOTopology(options)
}
getSchedulingTopology(options?: ReqConfig) {
return client.getInstance().getSchedulingTopology(options)
}
metricsQueryGet(params: {
endTimeSec?: number
query?: string
startTimeSec?: number
stepSec?: number
}) {
return client
.getInstance()
.metricsQueryGet(params, {
handleError: 'custom'
} as ReqConfig)
.then((res) => res.data)
}
getGrafanaTopology(options?: ReqConfig) {
return client.getInstance().getGrafanaTopology(options)
}
getAlertManagerTopology(options?: ReqConfig) {
return client.getInstance().getAlertManagerTopology(options)
}
getAlertManagerCounts(address: string, options?: ReqConfig) {
return client.getInstance().getAlertManagerCounts({ address }, options)
}
}
const ds = new DataSource()
export const ctx: IOverviewContext = {
ds,
cfg: {
apiPathBase: client.getBasePath(),
metricsQueries: overviewMetrics,
promAddrConfigurable: true,
showMetrics: true,
metricsReferenceLink:
'https://docs.pingcap.com/tidb/stable/dashboard-monitoring'
}
}