-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtypes.ts
246 lines (231 loc) · 5.9 KB
/
types.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
import { RequestHandler } from 'express';
//global error handler type
export type ServerError = {
log: string;
status: number;
message: { err: string };
};
export type MetricProps = {
graphType: GraphType;
lookupType: LookupType;
scopeType: ScopeType;
metricId?: string;
metricName?: string;
searchQuery?: string;
queryOptions?: any;
};
export interface UserData {
userId: string;
clusters: {}[];
clusterName: string;
dashboards: any;
metrics: {};
hiddenAlerts: [];
}
//represents properties on Node object passed from API request in K8s API controller to components on FE
export interface Node {
name: string;
namespace: any;
creationTimestamp: number | string;
labels: {}[];
uid: string;
providerID: string;
status: {};
}
//represents properties on Pod object passed from API request in K8s API controller to components on FE
export interface Pod {
name: string;
namespace: string;
nodeName: string;
creationTimestamp: string;
labels: [];
containers: [];
conditions: [];
serviceAccount: string;
containerStatuses: any;
podIP: string;
phase: string;
uid: string;
}
//represents properties on Namespace object passed from API request in K8s API controller to components on FE
export interface Namespace {
name: string;
creationTimestamp: string;
labels: [];
uid: string;
phase: string;
nodeName: string;
}
//represents properties on Service object passed from API request in K8s API controller to components on FE
export interface Service {
name: string;
namespace: string;
creationTimestamp: string;
labels: [];
uid: string;
ports: [];
loadBalancer: [];
clusterIP;
}
//represents properties on Deployment object passed from API request in K8s API controller to components on FE
export interface Deployment {
name: string;
creationTimestamp: string;
labels?: [];
namespace: string;
replicas: any;
uid: string;
status: {};
}
//represents properties on Cluster object passed from API request in K8s API controller to components on FE
export interface Cluster {
nodes: Node[];
pods: Pod[];
namespaces: Namespace[];
services: Service[];
deployments: Deployment[];
}
//filtering through alert data and cleaning it up for improved iteration
export interface CleanAlert {
name: string;
description: string;
summary: string;
severity: string;
affectedPod?: string | undefined;
affectedNamespace?: string | undefined;
startTime: string;
lastUpdated: string;
}
export enum LookupType {
// Default Dashboard
CustomEntry, //0
CPUUsage, // 1
CPUIdle, // 2
MemoryUsed, // 3
MemoryFreeInNode, // 4
MemoryIdle, // 5
DiskUsage, // 6
FreeDiskinNode, // 7
ReadyNodesByCluster, // 8
NodesReadinessFlapping, // 9
PodRestarts, //10
PodCount, // 11
// HPA Dashboard
HPAByDeployment, //12
HPATargetStatus, //13
HPATargetSpec, //14
HPAMinReplicas, //15
HPAMaxReplicas, //16
HPACurrentReplicas, //17
HPADesiredReplicas, //18
HPAUtilization, //19
HTTPRequests, //20
PodCountByHPA, //21
}
export enum ScopeType {
Range, //0
Instant, //1
}
export enum GraphType {
PrintValue, //0 Print Value or Bar Chart
LineGraph, //1
PieChart, //2
}
export const lookupName = (type: LookupType): string => {
switch (type) {
case LookupType.CustomEntry:
return 'Custom PromQL Entry';
case LookupType.CPUUsage:
return 'CPU Usage';
case LookupType.CPUIdle:
return 'CPU Underutilization';
case LookupType.MemoryUsed:
return 'Memory Usage by Container';
case LookupType.MemoryFreeInNode:
return 'Memory Available in Nodes (%)';
case LookupType.MemoryIdle:
return 'Memory Underutilization';
case LookupType.DiskUsage:
return 'Disk Usage';
case LookupType.FreeDiskinNode:
return 'Disk Space Available on Nodes (%)';
case LookupType.ReadyNodesByCluster:
return 'Ready Nodes by Cluster';
case LookupType.NodesReadinessFlapping:
return 'Node Readiness Flapping';
case LookupType.PodRestarts:
return 'Pod Restart Rates';
case LookupType.PodCount:
return 'Pod Counts';
case LookupType.HPAByDeployment:
return 'HPA by Deployment';
case LookupType.HPATargetStatus:
return 'HPATargetStatus';
case LookupType.HPATargetSpec:
return 'HPA Target Spec';
case LookupType.HPAMinReplicas:
return 'HPA Min Replicas';
case LookupType.HPAMaxReplicas:
return 'HPA Max Replicas';
case LookupType.HPACurrentReplicas:
return 'HPA Current Replicas';
case LookupType.HPADesiredReplicas:
return 'HPA Desired Replicas';
case LookupType.HPAUtilization:
return 'HPA Utilization';
case LookupType.HTTPRequests:
return 'HTTP Requests';
case LookupType.PodCountByHPA:
return 'Pod Count by HPA';
default:
return 'Lookup Type Not Found';
}
};
// types:
// object containing graph label and y-axis values
export type yAxis = {
label: string;
data: number[];
pointStyle?: boolean;
};
// object to send to front end to plot on a graph
export type plotData = {
labels: string[];
datasets: yAxis[];
options?: any;
};
// represents the objects stored in the Prometheus query response results array
export type promResResultElements = {
metric: {
__name__?: string;
container?: string;
cpu?: string;
device?: string;
endpoint?: string;
fstype?: string;
id?: string;
image?: string;
instance?: string;
job?: string;
metrics_path?: string;
mountpoint?: string;
name?: string;
namespace?: string;
node?: string;
pod?: string;
service?: string;
};
values: any[][];
};
// object representing the Prometheus query response object
export type promResponse = {
status: 'success' | 'error';
// only returned if status is "error"
errorType?: string;
error?: string;
// may or may not be included if the status is an error
data?: {
resultType: string;
result: promResResultElements[];
};
};