-
Notifications
You must be signed in to change notification settings - Fork 76
/
dashboard.go
458 lines (403 loc) · 14.9 KB
/
dashboard.go
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
package models
import "time"
type SearchModel struct {
Id int `json:"id"`
Enable bool `json:"enable"`
Name string `json:"name"`
SearchUrl string `json:"search_url"`
SearchCol string `json:"search_col"`
RefreshPanels bool `json:"refresh_panels"`
RefreshMessage bool `json:"refresh_message"`
}
type OptionModelSortList []*OptionModel
func (e OptionModelSortList) Len() int {
return len(e)
}
func (e OptionModelSortList) Swap(i, j int) {
e[i], e[j] = e[j], e[i]
}
func (e OptionModelSortList) Less(i, j int) bool {
return len(e[i].OptionText) < len(e[j].OptionText)
}
type OptionModel struct {
Id int `json:"id"`
OptionValue string `json:"option_value"`
OptionText string `json:"option_text"`
Active bool `json:"active"`
OptionType string `json:"type"`
OptionTypeName string `json:"option_type_name"`
}
type ButtonModel struct {
Id int `json:"id"`
GroupId int `json:"group_id"`
Name string `json:"name"`
BType string `json:"b_type"`
BText string `json:"b_text"`
RefreshPanels bool `json:"refresh_panels"`
RefreshCharts bool `json:"refresh_charts"`
OptionGroup int `json:"option_group"`
RefreshButton int `json:"refresh_button"`
RefreshButtonUrl string `json:"refresh_button_url"`
Options []*OptionModel `json:"option"`
}
type MessageModel struct {
Enable bool `json:"enable"`
Url string `json:"url"`
}
type PanelsModel struct {
Enable bool `json:"enable"`
Type string `json:"type"`
Url string `json:"url"`
}
type Dashboard struct {
Search SearchModel `json:"search"`
Buttons []*ButtonModel `json:"buttons"`
Message MessageModel `json:"message"`
Panels PanelsModel `json:"panels"`
}
type ChartModel struct {
Id int `json:"id"`
Col int `json:"col"`
Title string `json:"title"`
Endpoint []string `json:"endpoint"`
Metric []string `json:"metric"`
Url string `json:"url"`
Aggregate string `json:"aggregate"`
MonitorType string `json:"monitor_type"`
}
type PanelModel struct {
Title string `json:"title"`
Tags TagsModel `json:"tags"`
Other bool `json:"other"`
Charts []*ChartModel `json:"charts"`
}
type TagsModel struct {
Enable bool `json:"enable"`
Url string `json:"url"`
Option []*OptionModel `json:"option"`
}
type PanelTag struct {
Col int `json:"col"`
Endpoint []string `json:"endpoint"`
Metric []string `json:"metric"`
Url string `json:"url"`
}
type YaxisModel struct {
Unit string `json:"unit"`
}
type SerialModel struct {
Type string `json:"type"`
Name string `json:"name"`
Data [][]float64 `json:"data"`
}
type EChartOption struct {
Id int `json:"id"`
Title string `json:"title"`
Legend []string `json:"legend"`
Xaxis interface{} `json:"xaxis"`
Yaxis YaxisModel `json:"yaxis"`
Series []*SerialModel `json:"series"`
}
type EChartPie struct {
Title string `json:"title"`
Legend []string `json:"legend"`
Data []*EChartPieObj `json:"data"`
}
type EChartPieObj struct {
Name string `json:"name"`
Value float64 `json:"value"`
SourceValue []float64 `json:"-"`
}
type Chart struct {
Endpoint []string `json:"endpoint"`
Metric []string `json:"metric"`
Option EChartOption `json:"option"`
}
// DB Map struct
type DashboardTable struct {
Id int `json:"id"`
DashboardType string `json:"dashboard_type"`
SearchEnable bool `json:"search_enable"`
SearchId int `json:"search_id"`
ButtonEnable bool `json:"button_enable"`
ButtonGroup int `json:"button_group"`
MessageEnable bool `json:"message_enable"`
MessageGroup int `json:"message_group"`
MessageUrl string `json:"message_url"`
PanelsEnable bool `json:"panels_enable"`
PanelsType string `json:"panels_type"`
PanelsGroup int `json:"panels_group"`
PanelsParam string `json:"panels_param"`
}
type MessageTable struct {
Id int `json:"id"`
GroupId int `json:"group_id"`
K string `json:"k"`
Rename string `json:"rename"`
Col string `json:"col"`
Href bool `json:"href"`
Url string `json:"url"`
}
type PanelTable struct {
Id int `json:"id"`
GroupId int `json:"group_id"`
Title string `json:"title"`
TagsEnable bool `json:"tags_enable"`
TagsUrl string `json:"tags_url"`
TagsKey string `json:"tags_key"`
ChartGroup int `json:"chart_group"`
AutoDisplay int `json:"auto_display"`
ServiceGroup string `json:"service_group"`
}
type ChartTable struct {
Id int `json:"id"`
GroupId int `json:"group_id"`
Endpoint string `json:"endpoint"`
Metric string `json:"metric"`
Col int `json:"col"`
Url string `json:"url"`
Unit string `json:"unit"`
Title string `json:"title"`
GridType string `json:"grid_type"`
SeriesName string `json:"series_name"`
Rate bool `json:"rate"`
AggType string `json:"agg_type"`
Legend string `json:"legend"`
}
type ChartConfigObj struct {
Id int `form:"id" json:"id"`
Title string `form:"title" json:"title"`
Endpoint string `form:"endpoint" json:"endpoint"`
Metric string `form:"metric" json:"metric"`
PromQl string `form:"prom_ql" json:"prom_ql"`
Start string `form:"start" json:"start"`
End string `form:"end" json:"end"`
Time string `form:"time" json:"time"`
Aggregate string `form:"agg" json:"agg"`
CompareFirstStart string `form:"compare_first_start" json:"compare_first_start"`
CompareFirstEnd string `form:"compare_first_end" json:"compare_first_end"`
CompareSecondStart string `form:"compare_second_start" json:"compare_second_start"`
CompareSecondEnd string `form:"compare_second_end" json:"compare_second_end"`
AppObject string `form:"app_object" json:"app_object"`
AppObjectEndpointType string `form:"app_object_endpoint_type" json:"app_object_endpoint_type"`
}
type PieChartConfigObj struct {
Id int `form:"id" json:"id"`
Title string `form:"title" json:"title"`
Endpoint string `form:"endpoint" json:"endpoint"`
Metric string `form:"metric" json:"metric"`
PromQl string `form:"prom_ql" json:"prom_ql"`
Start int64 `form:"start" json:"start"`
End int64 `form:"end" json:"end"`
TimeSecond int64 `form:"time_second" json:"time_second"`
Aggregate string `form:"agg" json:"agg"`
CompareFirstStart string `form:"compare_first_start" json:"compare_first_start"`
CompareFirstEnd string `form:"compare_first_end" json:"compare_first_end"`
CompareSecondStart string `form:"compare_second_start" json:"compare_second_start"`
CompareSecondEnd string `form:"compare_second_end" json:"compare_second_end"`
AppObject string `form:"app_object" json:"app_object"`
AppObjectEndpointType string `form:"app_object_endpoint_type" json:"app_object_endpoint_type"`
PieMetricType string `form:"pie_metric_type" json:"pie_metric_type"`
PieAggType string `form:"pie_agg_type" json:"pie_agg_type"`
}
type ChartQueryParam struct {
ChartId int `json:"chart_id"`
Title string `json:"title"`
Unit string `json:"unit"`
Start int64 `json:"start"`
End int64 `json:"end"`
TimeSecond int64 `json:"time_second"`
Aggregate string `json:"aggregate"`
AggStep int64 `json:"agg_step"`
Step int `json:"step"`
Data []*ChartQueryConfigObj `json:"data"`
Compare *ChartQueryCompareParam `json:"compare"`
}
type ChartQueryConfigObj struct {
Endpoint string `json:"endpoint"`
Metric string `json:"metric"`
PromQl string `json:"prom_ql"`
AppObject string `json:"app_object"`
EndpointType string `json:"endpoint_type"`
}
type ChartQueryCompareParam struct {
CompareFirstStart string `json:"compare_first_start"`
CompareFirstEnd string `json:"compare_first_end"`
CompareSecondStart string `json:"compare_second_start"`
CompareSecondEnd string `json:"compare_second_end"`
CompareFirstLegend string `json:"compare_first_legend"`
CompareSecondLegend string `json:"compare_second_legend"`
CompareSecondStartTimestamp int64 `json:"compare_second_start_timestamp"`
CompareSecondEndTimestamp int64 `json:"compare_second_end_timestamp"`
CompareSubTime int64 `json:"compare_sub_time"`
}
type PromMetricUpdateParam struct {
Id int `json:"id"`
PanelId int `json:"panel_id"`
Chart PromMetricUpdateChartParam `json:"chart"`
Metric string `json:"metric" binding:"required"`
MetricType string `json:"metric_type"`
PromQl string `json:"prom_ql"`
PromMain string `json:"prom_main"`
}
type PromMetricUpdateChartParam struct {
Metric string `json:"metric"`
Title string `json:"title"`
Unit string `json:"unit"`
}
type PromMetricTable struct {
Id string `json:"id"`
Metric string `json:"metric" binding:"required"`
MetricType string `json:"metric_type"`
PromQl string `json:"prom_ql" binding:"required"`
PromMain string `json:"prom_main"`
}
type PromMetricObj struct {
Id string `json:"id"`
Metric string `json:"metric" binding:"required"`
MetricType string `json:"metric_type"`
PromQl string `json:"prom_expr" binding:"required"`
PromMain string `json:"prom_main"`
ServiceGroup string `json:"service_group"`
Workspace string `json:"workspace"`
}
type EndpointTable struct {
Id int `json:"id"`
Guid string `json:"guid"`
Name string `json:"name"`
Ip string `json:"ip"`
EndpointVersion string `json:"endpoint_version"`
ExportType string `json:"export_type"`
ExportVersion string `json:"export_version"`
Step int `json:"step"`
Address string `json:"address"`
OsType string `json:"os_type"`
CreateAt string `json:"create_at"`
StopAlarm int `json:"stop_alarm"`
AddressAgent string `json:"address_agent"`
Cluster string `json:"cluster"`
Tags string `json:"tags"`
UpdateAt time.Time `json:"update_at"`
}
type EndpointMetricTable struct {
Id int `json:"id"`
EndpointId int `json:"endpoint_id"`
Metric string `json:"metric"`
}
type MaintainTable struct {
Id int `json:"id"`
EndpointId int `json:"endpoint_id"`
MaintainStart time.Time `json:"maintain_start"`
MaintainEnd time.Time `json:"maintain_end"`
MaintainUser string `json:"maintain_user"`
}
type MaintainDto struct {
Start int64 `json:"start"`
End int64 `json:"end"`
Endpoint string `json:"endpoint"`
Ip string `json:"ip"`
EndpointType string `json:"endpoint_type"`
ClearMaintain bool `json:"clear_maintain"`
}
type CustomDashboardTable struct {
Id int `json:"id"`
Name string `json:"name"`
PanelsGroup int `json:"panels_group"`
Cfg string `json:"cfg"`
Main int `json:"main"`
CreateUser string `json:"create_user"`
UpdateUser string `json:"update_user"`
CreateAt time.Time `json:"create_at"`
UpdateAt time.Time `json:"update_at"`
PanelGroups string `json:"panel_groups"`
}
type CustomDashboardObj struct {
CustomDashboardTable
PanelGroupList []string `json:"panel_group_list"`
}
type CustomDashboardQuery struct {
Id int `json:"id"`
Name string `json:"name"`
PanelsGroup int `json:"panels_group"`
Cfg string `json:"cfg"`
Main int `json:"main"`
CreateUser string `json:"create_user"`
UpdateUser string `json:"update_user"`
CreateAt time.Time `json:"create_at"`
UpdateAt time.Time `json:"update_at"`
MainPage []string `json:"main_page"`
Permission string `json:"permission"`
PanelGroups string `json:"panel_groups"`
PanelGroupList []string `json:"panel_group_list"`
}
type MainPageRoleQuery struct {
RoleName string `json:"role_name"`
MainPageId int `json:"main_page_id"`
MainPageName string `json:"main_page_name"`
Options []*OptionModel `json:"options"`
}
type UpdateChartTitleParam struct {
ChartId int `json:"chart_id"`
Metric string `json:"metric"`
Name string `json:"name" binding:"required"`
}
type DisplayDemoFlagDto struct {
Display bool `json:"display"`
}
type CustomerDashboardRoleQuery struct {
Id int `json:"id"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
Permission string `json:"permission"`
}
type CustomDashboardRoleDto struct {
DashboardId int `json:"dashboard_id" binding:"required"`
//RoleId []int `json:"role_id"`
PermissionList []*CustomDashboardRoleObj `json:"permission_list"`
}
type CustomDashboardRoleObj struct {
RoleId int `json:"role_id"`
Permission string `json:"permission"`
}
type CustomDashboardConfigObj struct {
Query []*CustomDashboardConfigQueryObj `json:"query"`
}
type CustomDashboardConfigQueryObj struct {
Endpoint string `json:"endpoint"`
MetricLabel string `json:"metricLabel"`
Metric string `json:"metric"`
AppObject string `json:"app_object"`
EndpointType string `json:"endpoint_type"`
}
type PanelChartQueryObj struct {
Id int `json:"id"`
TagsKey string `json:"tags_key"`
Title string `json:"title"`
GroupId int `json:"group_id"`
Metric string `json:"metric"`
ChartTitle string `json:"chart_title"`
ChartUnit string `json:"chart_unit"`
}
type PanelResult struct {
PanelList []*PanelResultObj `json:"panel_list"`
ActiveChart PanelResultChartObj `json:"active_chart"`
PanelGroupId int `json:"panel_group_id"`
}
type PanelResultObj struct {
GroupId int `json:"group_id"`
PanelTitle string `json:"panel_title"`
TagsKey string `json:"tags_key"`
Charts []*PanelResultChartObj `json:"charts"`
}
type PanelResultChartObj struct {
Metric string `json:"metric"`
Title string `json:"title"`
Unit string `json:"unit"`
Active bool `json:"active"`
}
type GetEndpointMetricParam struct {
Guid string `json:"guid"`
MonitorType string `json:"monitor_type" binding:"required"`
ServiceGroup string `json:"service_group"`
Workspace string `json:"workspace"`
}