-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy patha-n9e.sql
689 lines (639 loc) · 41.4 KB
/
a-n9e.sql
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
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
set names utf8mb4;
drop database if exists n9e_v6;
create database n9e_v6;
use n9e_v6;
CREATE TABLE `users` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`username` varchar(64) NOT NULL COMMENT 'login name, cannot rename',
`nickname` varchar(64) NOT NULL COMMENT 'display name, chinese name',
`password` varchar(128) NOT NULL DEFAULT '',
`phone` varchar(16) NOT NULL DEFAULT '',
`email` varchar(64) NOT NULL DEFAULT '',
`portrait` varchar(255) NOT NULL DEFAULT '' COMMENT 'portrait image url',
`roles` varchar(255) NOT NULL COMMENT 'Admin | Standard | Guest, split by space',
`contacts` varchar(1024) NULL DEFAULT NULL COMMENT 'json e.g. {wecom:xx, dingtalk_robot_token:yy}',
`maintainer` tinyint(1) NOT NULL DEFAULT 0,
`create_at` bigint NOT NULL DEFAULT 0,
`create_by` varchar(64) NOT NULL DEFAULT '',
`update_at` bigint NOT NULL DEFAULT 0,
`update_by` varchar(64) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY (`username`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
insert into `users`(id, username, nickname, password, roles, create_at, create_by, update_at, update_by) values(1, 'root', '超管', 'root.2020', 'Admin', unix_timestamp(now()), 'system', unix_timestamp(now()), 'system');
CREATE TABLE `user_group` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(128) NOT NULL DEFAULT '',
`note` varchar(255) NOT NULL DEFAULT '',
`create_at` bigint NOT NULL DEFAULT 0,
`create_by` varchar(64) NOT NULL DEFAULT '',
`update_at` bigint NOT NULL DEFAULT 0,
`update_by` varchar(64) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY (`create_by`),
KEY (`update_at`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
insert into user_group(id, name, create_at, create_by, update_at, update_by) values(1, 'demo-root-group', unix_timestamp(now()), 'root', unix_timestamp(now()), 'root');
CREATE TABLE `user_group_member` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`group_id` bigint UNSIGNED NOT NULL,
`user_id` bigint UNSIGNED NOT NULL,
PRIMARY KEY (`id`),
KEY (`group_id`),
KEY (`user_id`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
insert into user_group_member(group_id, user_id) values(1, 1);
CREATE TABLE `configs` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`ckey` varchar(191) NOT NULL,
`cval` text NULL COMMENT 'config value',
`note` varchar(1024) NULL DEFAULT '' COMMENT 'note',
`external` bigint NULL DEFAULT 0 COMMENT '0:built-in 1:external',
`encrypted` bigint NULL DEFAULT 0 COMMENT '0:plaintext 1:ciphertext',
`create_at` bigint NULL DEFAULT 0 COMMENT 'create_at',
`create_by` varchar(64) NULL DEFAULT '' COMMENT 'cerate_by',
`update_at` bigint NULL DEFAULT 0 COMMENT 'update_at',
`update_by` varchar(64) NULL DEFAULT '' COMMENT 'update_by',
PRIMARY KEY (`id`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
CREATE TABLE `role` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(191) NOT NULL DEFAULT '',
`note` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY (`name`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
insert into `role`(name, note) values('Admin', 'Administrator role');
insert into `role`(name, note) values('Standard', 'Ordinary user role');
insert into `role`(name, note) values('Guest', 'Readonly user role');
CREATE TABLE `role_operation` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`role_name` varchar(128) NOT NULL,
`operation` varchar(191) NOT NULL,
PRIMARY KEY (`id`),
KEY (`role_name`),
KEY (`operation`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
-- Admin is special, who has no concrete operation but can do anything.
INSERT INTO `role_operation`(role_name, operation) VALUES ('Guest', '/metric/explorer');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Guest', '/object/explorer');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Guest', '/log/explorer');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Guest', '/trace/explorer');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Guest', '/help/version');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Guest', '/help/contact');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Admin', '/help/source');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Admin', '/help/sso');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Admin', '/help/notification-tpls');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Admin', '/help/notification-settings');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Admin', '/permissions');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/metric/explorer');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/object/explorer');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/log/explorer');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/trace/explorer');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/help/version');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/help/contact');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/help/servers');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/help/migrate');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/alert-rules-built-in');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/dashboards-built-in');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/trace/dependencies');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/users');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/user-groups');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/user-groups/add');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/user-groups/put');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/user-groups/del');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/busi-groups');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/busi-groups/add');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/busi-groups/put');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/busi-groups/del');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/targets');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/targets/add');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/targets/put');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/targets/del');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/dashboards');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/dashboards/add');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/dashboards/put');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/dashboards/del');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/alert-rules');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/alert-rules/add');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/alert-rules/put');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/alert-rules/del');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/alert-mutes');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/alert-mutes/add');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/alert-mutes/del');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/alert-subscribes');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/alert-subscribes/add');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/alert-subscribes/put');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/alert-subscribes/del');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/alert-cur-events');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/alert-cur-events/del');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/alert-his-events');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/job-tpls');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/job-tpls/add');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/job-tpls/put');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/job-tpls/del');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/job-tasks');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/job-tasks/add');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/job-tasks/put');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/recording-rules');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/recording-rules/add');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/recording-rules/put');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/recording-rules/del');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/alert-mutes/put');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/log/index-patterns');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/help/variable-configs');
INSERT INTO `role_operation`(role_name, operation) VALUES ('Standard', '/ibex-settings');
-- for alert_rule | collect_rule | mute | dashboard grouping
CREATE TABLE `busi_group` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(191) NOT NULL,
`label_enable` tinyint(1) NOT NULL DEFAULT 0,
`label_value` varchar(191) NOT NULL DEFAULT '' COMMENT 'if label_enable: label_value can not be blank',
`create_at` bigint NOT NULL DEFAULT 0,
`create_by` varchar(64) NOT NULL DEFAULT '',
`update_at` bigint NOT NULL DEFAULT 0,
`update_by` varchar(64) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY (`name`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
insert into busi_group(id, name, create_at, create_by, update_at, update_by) values(1, 'Default Busi Group', unix_timestamp(now()), 'root', unix_timestamp(now()), 'root');
CREATE TABLE `busi_group_member` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`busi_group_id` bigint NOT NULL COMMENT 'busi group id',
`user_group_id` bigint NOT NULL COMMENT 'user group id',
`perm_flag` char(2) NOT NULL COMMENT 'ro | rw',
PRIMARY KEY (`id`),
KEY (`busi_group_id`),
KEY (`user_group_id`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
insert into busi_group_member(busi_group_id, user_group_id, perm_flag) values(1, 1, 'rw');
-- for dashboard new version
CREATE TABLE `board` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`group_id` bigint NOT NULL DEFAULT 0 COMMENT 'busi group id',
`name` varchar(191) NOT NULL,
`ident` varchar(200) NOT NULL DEFAULT '',
`tags` varchar(255) NOT NULL COMMENT 'split by space',
`is_public` tinyint(1) NOT NULL DEFAULT 0 COMMENT '0:false 1:true',
`built_in` tinyint(1) NOT NULL DEFAULT 0 COMMENT '0:false 1:true',
`hide` tinyint(1) NOT NULL DEFAULT 0 COMMENT '0:false 1:true',
`create_at` bigint NOT NULL DEFAULT 0,
`create_by` varchar(64) NOT NULL DEFAULT '',
`update_at` bigint NOT NULL DEFAULT 0,
`update_by` varchar(64) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY (`group_id`, `name`),
KEY(`ident`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
-- for dashboard new version
CREATE TABLE `board_payload` (
`id` bigint UNSIGNED NOT NULL COMMENT 'dashboard id',
`payload` mediumtext NOT NULL,
UNIQUE KEY (`id`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
-- deprecated
CREATE TABLE `dashboard` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`group_id` bigint NOT NULL DEFAULT 0 COMMENT 'busi group id',
`name` varchar(191) NOT NULL,
`tags` varchar(255) NOT NULL COMMENT 'split by space',
`configs` varchar(8192) NULL DEFAULT NULL COMMENT 'dashboard variables',
`create_at` bigint NOT NULL DEFAULT 0,
`create_by` varchar(64) NOT NULL DEFAULT '',
`update_at` bigint NOT NULL DEFAULT 0,
`update_by` varchar(64) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY (`group_id`, `name`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
-- deprecated
-- auto create the first subclass 'Default chart group' of dashboard
CREATE TABLE `chart_group` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`dashboard_id` bigint UNSIGNED NOT NULL,
`name` varchar(255) NOT NULL,
`weight` int NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
KEY (`dashboard_id`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
-- deprecated
CREATE TABLE `chart` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`group_id` bigint UNSIGNED NOT NULL COMMENT 'chart group id',
`configs` text NULL,
`weight` int NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
KEY (`group_id`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
CREATE TABLE `chart_share` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`cluster_name` varchar(128) NOT NULL,
`datasource_id` bigint NOT NULL DEFAULT 0 COMMENT 'datasource id',
`configs` text NULL,
`create_at` bigint NOT NULL DEFAULT 0,
`create_by` varchar(64) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
key (`create_at`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
CREATE TABLE `alert_rule` (
`id` bigint unsigned not null auto_increment,
`group_id` bigint not null default 0 comment 'busi group id',
`cate` varchar(128) not null,
`datasource_ids` varchar(255) not null default '' comment 'datasource ids',
`cluster_name` varchar(128) not null,
`name` varchar(255) not null,
`note` varchar(1024) not null default '',
`prod` varchar(255) not null default '',
`algorithm` varchar(255) not null default '',
`algo_params` varchar(255),
`delay` int not null default 0,
`severity` tinyint(1) not null comment '1:Emergency 2:Warning 3:Notice',
`disabled` tinyint(1) not null comment '0:enabled 1:disabled',
`prom_for_duration` int not null comment 'prometheus for, unit:s',
`rule_config` text not null comment 'rule_config',
`prom_ql` text not null comment 'promql',
`prom_eval_interval` int not null comment 'evaluate interval',
`enable_stime` varchar(255) not null default '00:00',
`enable_etime` varchar(255) not null default '23:59',
`enable_days_of_week` varchar(255) not null default '' comment 'split by space: 0 1 2 3 4 5 6',
`enable_in_bg` tinyint(1) not null default 0 comment '1: only this bg 0: global',
`notify_recovered` tinyint(1) not null comment 'whether notify when recovery',
`notify_channels` varchar(255) not null default '' comment 'split by space: sms voice email dingtalk wecom',
`notify_groups` varchar(255) not null default '' comment 'split by space: 233 43',
`notify_repeat_step` int not null default 0 comment 'unit: min',
`notify_max_number` int not null default 0 comment '',
`recover_duration` int not null default 0 comment 'unit: s',
`callbacks` varchar(1024) not null default '' comment 'split by space: http://a.com/api/x http://a.com/api/y',
`runbook_url` varchar(255),
`append_tags` varchar(255) not null default '' comment 'split by space: service=n9e mod=api',
`annotations` text not null comment 'annotations',
`extra_config` text not null comment 'extra_config',
`create_at` bigint not null default 0,
`create_by` varchar(64) not null default '',
`update_at` bigint not null default 0,
`update_by` varchar(64) not null default '',
PRIMARY KEY (`id`),
KEY (`group_id`),
KEY (`update_at`)
) ENGINE=InnoDB DEFAULT CHARSET = utf8mb4;
CREATE TABLE `alert_mute` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`group_id` bigint NOT NULL DEFAULT 0 COMMENT 'busi group id',
`prod` varchar(255) NOT NULL DEFAULT '',
`note` varchar(1024) NOT NULL DEFAULT '',
`cate` varchar(128) NOT NULL,
`cluster_name` varchar(128) NOT NULL,
`datasource_ids` varchar(255) NOT NULL DEFAULT '' COMMENT 'datasource ids',
`tags` varchar(4096) NOT NULL DEFAULT '' COMMENT 'json,map,tagkey->regexp|value',
`cause` varchar(255) NOT NULL DEFAULT '',
`btime` bigint NOT NULL DEFAULT 0 COMMENT 'begin time',
`etime` bigint NOT NULL DEFAULT 0 COMMENT 'end time',
`disabled` tinyint(1) NOT NULL DEFAULT 0 COMMENT '0:enabled 1:disabled',
`mute_time_type` tinyint(1) NOT NULL DEFAULT 0,
`periodic_mutes` varchar(4096) NOT NULL DEFAULT '',
`severities` varchar(32) NOT NULL DEFAULT '',
`create_at` bigint NOT NULL DEFAULT 0,
`create_by` varchar(64) NOT NULL DEFAULT '',
`update_at` bigint NOT NULL DEFAULT 0,
`update_by` varchar(64) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY (`create_at`),
KEY (`group_id`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
CREATE TABLE `alert_subscribe` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL DEFAULT '',
`disabled` tinyint(1) NOT NULL DEFAULT 0 COMMENT '0:enabled 1:disabled',
`group_id` bigint NOT NULL DEFAULT 0 COMMENT 'busi group id',
`prod` varchar(255) NOT NULL DEFAULT '',
`cate` varchar(128) NOT NULL,
`datasource_ids` varchar(255) NOT NULL DEFAULT '' COMMENT 'datasource ids',
`cluster_name` varchar(128) NOT NULL,
`rule_id` bigint NOT NULL DEFAULT 0,
`severities` varchar(32) NOT NULL DEFAULT '',
`tags` varchar(4096) NOT NULL DEFAULT '' COMMENT 'json,map,tagkey->regexp|value',
`redefine_severity` tinyint(1) NULL DEFAULT 0 COMMENT 'is redefine severity?',
`new_severity` tinyint(1) NOT NULL COMMENT '0:Emergency 1:Warning 2:Notice',
`redefine_channels` tinyint(1) NULL DEFAULT 0 COMMENT 'is redefine channels?',
`new_channels` varchar(255) NOT NULL DEFAULT '' COMMENT 'split by space: sms voice email dingtalk wecom',
`user_group_ids` varchar(250) NOT NULL COMMENT 'split by space 1 34 5, notify cc to user_group_ids',
`webhooks` text NOT NULL,
`extra_config` text NULL,
`redefine_webhooks` tinyint(1) NULL DEFAULT 0,
`for_duration` bigint NOT NULL DEFAULT 0,
`note` varchar(1024) NULL DEFAULT '' COMMENT 'note',
`create_at` bigint NOT NULL DEFAULT 0,
`create_by` varchar(64) NOT NULL DEFAULT '',
`update_at` bigint NOT NULL DEFAULT 0,
`update_by` varchar(64) NOT NULL DEFAULT '',
`busi_groups` varchar(4096) NOT NULL DEFAULT '[]',
PRIMARY KEY (`id`),
KEY (`update_at`),
KEY (`group_id`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
CREATE TABLE `target` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`group_id` bigint NOT NULL DEFAULT 0 COMMENT 'busi group id',
`ident` varchar(191) NOT NULL COMMENT 'target id',
`note` varchar(255) NOT NULL DEFAULT '' COMMENT 'append to alert event as field',
`tags` varchar(512) NOT NULL DEFAULT '' COMMENT 'append to series data as tags, split by space, append external space at suffix',
`update_at` bigint NOT NULL DEFAULT 0,
`host_ip` varchar(191) NULL DEFAULT '' COMMENT 'IPv4 string',
`agent_version` varchar(255) NULL DEFAULT '' COMMENT 'agent version',
PRIMARY KEY (`id`),
UNIQUE KEY (`ident`),
INDEX idx_host_ip(`host_ip`),
INDEX idx_agent_version(`agent_version`),
KEY (`group_id`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
-- case1: target_idents; case2: target_tags
-- CREATE TABLE `collect_rule` (
-- `id` bigint unsigned not null auto_increment,
-- `group_id` bigint not null default 0 comment 'busi group id',
-- `cluster` varchar(128) not null,
-- `target_idents` varchar(512) not null default '' comment 'ident list, split by space',
-- `target_tags` varchar(512) not null default '' comment 'filter targets by tags, split by space',
-- `name` varchar(191) not null default '',
-- `note` varchar(255) not null default '',
-- `step` int not null,
-- `type` varchar(64) not null comment 'e.g. port proc log plugin',
-- `data` text not null,
-- `append_tags` varchar(255) not null default '' comment 'split by space: e.g. mod=n9e dept=cloud',
-- `create_at` bigint not null default 0,
-- `create_by` varchar(64) not null default '',
-- `update_at` bigint not null default 0,
-- `update_by` varchar(64) not null default '',
-- PRIMARY KEY (`id`),
-- KEY (`group_id`, `type`, `name`)
-- ) ENGINE=InnoDB DEFAULT CHARSET = utf8mb4;
CREATE TABLE `metric_view` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(191) NOT NULL DEFAULT '',
`cate` tinyint(1) NOT NULL COMMENT '0: preset 1: custom',
`configs` varchar(8192) NOT NULL DEFAULT '',
`create_at` bigint NOT NULL DEFAULT 0,
`create_by` bigint NOT NULL DEFAULT 0 COMMENT 'user id',
`update_at` bigint NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
KEY (`create_by`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
insert into metric_view(name, cate, configs) values('Host View', 0, '{"filters":[{"oper":"=","label":"__name__","value":"cpu_usage_idle"}],"dynamicLabels":[],"dimensionLabels":[{"label":"ident","value":""}]}');
CREATE TABLE `recording_rule` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`group_id` bigint NOT NULL DEFAULT 0 COMMENT 'group_id',
`datasource_ids` varchar(255) NOT NULL DEFAULT '' COMMENT 'datasource ids',
`cluster_name` varchar(128) NOT NULL,
`name` varchar(255) NOT NULL COMMENT 'new metric name',
`note` varchar(255) NOT NULL COMMENT 'rule note',
`disabled` tinyint(1) NOT NULL DEFAULT 0 COMMENT '0:enabled 1:disabled',
`prom_ql` varchar(8192) NOT NULL COMMENT 'promql',
`prom_eval_interval` int NOT NULL COMMENT 'evaluate interval',
`append_tags` varchar(255) NULL DEFAULT '' COMMENT 'split by space: service=n9e mod=api',
`query_configs` text NOT NULL,
`create_at` bigint NULL DEFAULT 0,
`create_by` varchar(64) NULL DEFAULT '',
`update_at` bigint NULL DEFAULT 0,
`update_by` varchar(64) NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `group_id` (`group_id`),
KEY `update_at` (`update_at`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
CREATE TABLE `alert_aggr_view` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(191) NOT NULL DEFAULT '',
`rule` varchar(2048) NOT NULL DEFAULT '',
`cate` tinyint(1) NOT NULL COMMENT '0: preset 1: custom',
`create_at` bigint NOT NULL DEFAULT 0,
`create_by` bigint NOT NULL DEFAULT 0 COMMENT 'user id',
`update_at` bigint NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
KEY (`create_by`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
insert into alert_aggr_view(name, rule, cate) values('By BusiGroup, Severity', 'field:group_name::field:severity', 0);
insert into alert_aggr_view(name, rule, cate) values('By RuleName', 'field:rule_name', 0);
CREATE TABLE `alert_cur_event` (
`id` bigint UNSIGNED NOT NULL COMMENT 'use alert_his_event.id',
`cate` varchar(128) NOT NULL,
`datasource_id` bigint NOT NULL DEFAULT 0 COMMENT 'datasource id',
`cluster_name` varchar(128) NOT NULL,
`group_id` bigint UNSIGNED NOT NULL COMMENT 'busi group id of rule',
`group_name` varchar(255) NOT NULL DEFAULT '' COMMENT 'busi group name',
`hash` varchar(64) NOT NULL COMMENT 'rule_id + vector_pk',
`rule_id` bigint UNSIGNED NOT NULL,
`rule_name` varchar(255) NOT NULL,
`rule_note` varchar(2048) NOT NULL DEFAULT 'alert rule note',
`rule_prod` varchar(255) NOT NULL DEFAULT '',
`rule_algo` varchar(255) NOT NULL DEFAULT '',
`severity` tinyint(1) NOT NULL COMMENT '0:Emergency 1:Warning 2:Notice',
`prom_for_duration` int NOT NULL COMMENT 'prometheus for, unit:s',
`prom_ql` varchar(8192) NOT NULL COMMENT 'promql',
`prom_eval_interval` int NOT NULL COMMENT 'evaluate interval',
`callbacks` varchar(255) NOT NULL DEFAULT '' COMMENT 'split by space: http://a.com/api/x http://a.com/api/y',
`runbook_url` varchar(255) NULL DEFAULT NULL,
`notify_recovered` tinyint(1) NOT NULL COMMENT 'whether notify when recovery',
`notify_channels` varchar(255) NOT NULL DEFAULT '' COMMENT 'split by space: sms voice email dingtalk wecom',
`notify_groups` varchar(255) NOT NULL DEFAULT '' COMMENT 'split by space: 233 43',
`notify_repeat_next` bigint NOT NULL DEFAULT 0 COMMENT 'next timestamp to notify, get repeat settings from rule',
`notify_cur_number` int NOT NULL DEFAULT 0,
`target_ident` varchar(191) NOT NULL DEFAULT '' COMMENT 'target ident, also in tags',
`target_note` varchar(191) NOT NULL DEFAULT '' COMMENT 'target note',
`first_trigger_time` bigint NULL DEFAULT NULL,
`trigger_time` bigint NOT NULL,
`trigger_value` varchar(255) NOT NULL,
`annotations` text NOT NULL COMMENT 'annotations',
`rule_config` text NOT NULL COMMENT 'annotations',
`tags` varchar(1024) NOT NULL DEFAULT '' COMMENT 'merge data_tags rule_tags, split by ,,',
PRIMARY KEY (`id`),
KEY (`hash`),
KEY (`rule_id`),
KEY (`trigger_time`, `group_id`),
KEY (`notify_repeat_next`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
CREATE TABLE `alert_his_event` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`is_recovered` tinyint(1) NOT NULL,
`cate` varchar(128) NOT NULL,
`datasource_id` bigint NOT NULL DEFAULT 0 COMMENT 'datasource id',
`cluster_name` varchar(128) NOT NULL,
`group_id` bigint UNSIGNED NOT NULL COMMENT 'busi group id of rule',
`group_name` varchar(255) NOT NULL DEFAULT '' COMMENT 'busi group name',
`hash` varchar(64) NOT NULL COMMENT 'rule_id + vector_pk',
`rule_id` bigint UNSIGNED NOT NULL,
`rule_name` varchar(255) NOT NULL,
`rule_note` varchar(2048) NOT NULL DEFAULT 'alert rule note',
`rule_prod` varchar(255) NOT NULL DEFAULT '',
`rule_algo` varchar(255) NOT NULL DEFAULT '',
`severity` tinyint(1) NOT NULL COMMENT '0:Emergency 1:Warning 2:Notice',
`prom_for_duration` int NOT NULL COMMENT 'prometheus for, unit:s',
`prom_ql` varchar(8192) NOT NULL COMMENT 'promql',
`prom_eval_interval` int NOT NULL COMMENT 'evaluate interval',
`callbacks` varchar(255) NOT NULL DEFAULT '' COMMENT 'split by space: http://a.com/api/x http://a.com/api/y',
`runbook_url` varchar(255) NULL DEFAULT NULL,
`notify_recovered` tinyint(1) NOT NULL COMMENT 'whether notify when recovery',
`notify_channels` varchar(255) NOT NULL DEFAULT '' COMMENT 'split by space: sms voice email dingtalk wecom',
`notify_groups` varchar(255) NOT NULL DEFAULT '' COMMENT 'split by space: 233 43',
`notify_cur_number` int NOT NULL DEFAULT 0,
`target_ident` varchar(191) NOT NULL DEFAULT '' COMMENT 'target ident, also in tags',
`target_note` varchar(191) NOT NULL DEFAULT '' COMMENT 'target note',
`first_trigger_time` bigint NULL DEFAULT NULL,
`trigger_time` bigint NOT NULL,
`trigger_value` varchar(255) NOT NULL,
`recover_time` bigint NOT NULL DEFAULT 0,
`last_eval_time` bigint NOT NULL DEFAULT 0 COMMENT 'for time filter',
`tags` varchar(1024) NOT NULL DEFAULT '' COMMENT 'merge data_tags rule_tags, split by ,,',
`annotations` text NOT NULL COMMENT 'annotations',
`rule_config` text NOT NULL COMMENT 'annotations',
PRIMARY KEY (`id`),
KEY (`hash`),
KEY (`rule_id`),
KEY (`trigger_time`, `group_id`),
KEY (`last_eval_time`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
CREATE TABLE `task_tpl` (
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
`group_id` int UNSIGNED NOT NULL COMMENT 'busi group id',
`title` varchar(255) NOT NULL DEFAULT '',
`account` varchar(64) NOT NULL,
`batch` int UNSIGNED NOT NULL DEFAULT 0,
`tolerance` int UNSIGNED NOT NULL DEFAULT 0,
`timeout` int UNSIGNED NOT NULL DEFAULT 0,
`pause` varchar(255) NOT NULL DEFAULT '',
`script` text NOT NULL,
`args` varchar(512) NOT NULL DEFAULT '',
`tags` varchar(255) NOT NULL DEFAULT '' COMMENT 'split by space',
`create_at` bigint NOT NULL DEFAULT 0,
`create_by` varchar(64) NOT NULL DEFAULT '',
`update_at` bigint NOT NULL DEFAULT 0,
`update_by` varchar(64) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY (`group_id`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
CREATE TABLE `task_tpl_host` (
`ii` int UNSIGNED NOT NULL AUTO_INCREMENT,
`id` int UNSIGNED NOT NULL COMMENT 'task tpl id',
`host` varchar(128) NOT NULL COMMENT 'ip or hostname',
PRIMARY KEY (`ii`),
KEY (`id`, `host`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
CREATE TABLE `task_record` (
`id` bigint UNSIGNED NOT NULL COMMENT 'ibex task id',
`event_id` bigint NOT NULL DEFAULT 0 COMMENT 'event id',
`group_id` bigint NOT NULL COMMENT 'busi group id',
`ibex_address` varchar(128) NOT NULL,
`ibex_auth_user` varchar(128) NOT NULL DEFAULT '',
`ibex_auth_pass` varchar(128) NOT NULL DEFAULT '',
`title` varchar(255) NOT NULL DEFAULT '',
`account` varchar(64) NOT NULL,
`batch` int UNSIGNED NOT NULL DEFAULT 0,
`tolerance` int UNSIGNED NOT NULL DEFAULT 0,
`timeout` int UNSIGNED NOT NULL DEFAULT 0,
`pause` varchar(255) NOT NULL DEFAULT '',
`script` text NOT NULL,
`args` varchar(512) NOT NULL DEFAULT '',
`create_at` bigint NOT NULL DEFAULT 0,
`create_by` varchar(64) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY (`create_at`, `group_id`),
KEY (`create_by`),
KEY (`event_id`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
CREATE TABLE `alerting_engines` (
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
`instance` varchar(128) NOT NULL DEFAULT '' COMMENT 'instance identification, e.g. 10.9.0.9:9090',
`datasource_id` bigint NOT NULL DEFAULT 0 COMMENT 'datasource id',
`engine_cluster` varchar(128) NOT NULL DEFAULT '' COMMENT 'n9e-alert cluster',
`clock` bigint NOT NULL,
PRIMARY KEY (`id`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
CREATE TABLE `datasource` (
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(191) NOT NULL DEFAULT '',
`description` varchar(255) NOT NULL DEFAULT '',
`category` varchar(255) NOT NULL DEFAULT '',
`plugin_id` int UNSIGNED NOT NULL DEFAULT 0,
`plugin_type` varchar(255) NOT NULL DEFAULT '',
`plugin_type_name` varchar(255) NOT NULL DEFAULT '',
`cluster_name` varchar(255) NOT NULL DEFAULT '',
`settings` text NOT NULL,
`status` varchar(255) NOT NULL DEFAULT '',
`http` varchar(4096) NOT NULL DEFAULT '',
`auth` varchar(8192) NOT NULL DEFAULT '',
`created_at` bigint NOT NULL DEFAULT 0,
`created_by` varchar(64) NOT NULL DEFAULT '',
`updated_at` bigint NOT NULL DEFAULT 0,
`updated_by` varchar(64) NOT NULL DEFAULT '',
`is_default` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is default datasource',
PRIMARY KEY (`id`),
UNIQUE KEY (`name`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
CREATE TABLE `builtin_cate` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(191) NOT NULL,
`user_id` bigint NOT NULL DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
CREATE TABLE `notify_tpl` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`channel` varchar(32) NOT NULL,
`name` varchar(255) NOT NULL,
`content` text NOT NULL,
`create_at` INT DEFAULT 0 COMMENT 'create_at',
`create_by` VARCHAR(64) DEFAULT '' COMMENT 'create_by',
`update_at` INT DEFAULT 0 COMMENT 'update_at',
`update_by` VARCHAR(64) DEFAULT '' COMMENT 'update_by',
PRIMARY KEY (`id`),
UNIQUE KEY (`channel`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
INSERT INTO `notify_tpl`(id,channel,name,content) VALUES (1, 'telegram', 'telegram', '**级别状态**: {{if .IsRecovered}}<font color=\"info\">S{{.Severity}} Recovered</font>{{else}}<font color=\"warning\">S{{.Severity}} Triggered</font>{{end}} \n**规则标题**: {{.RuleName}}{{if .RuleNote}} \n**规则备注**: {{.RuleNote}}{{end}}{{if .TargetIdent}} \n**监控对象**: {{.TargetIdent}}{{end}} \n**监控指标**: {{.TagsJSON}}{{if not .IsRecovered}} \n**触发时值**: {{.TriggerValue}}{{end}} \n{{if .IsRecovered}}**恢复时间**: {{timeformat .LastEvalTime}}{{else}}**首次触发时间**: {{timeformat .FirstTriggerTime}}{{end}} \n{{$time_duration := sub now.Unix .FirstTriggerTime }}{{if .IsRecovered}}{{$time_duration = sub .LastEvalTime .FirstTriggerTime }}{{end}}**距离首次告警**: {{humanizeDurationInterface $time_duration}}\n**发送时间**: {{timestamp}}');
INSERT INTO `notify_tpl`(id,channel,name,content) VALUES (2, 'wecom', 'wecom', '**级别状态**: {{if .IsRecovered}}<font color=\"info\">S{{.Severity}} Recovered</font>{{else}}<font color=\"warning\">S{{.Severity}} Triggered</font>{{end}} \n**规则标题**: {{.RuleName}}{{if .RuleNote}} \n**规则备注**: {{.RuleNote}}{{end}}{{if .TargetIdent}} \n**监控对象**: {{.TargetIdent}}{{end}} \n**监控指标**: {{.TagsJSON}}{{if not .IsRecovered}} \n**触发时值**: {{.TriggerValue}}{{end}} \n{{if .IsRecovered}}**恢复时间**: {{timeformat .LastEvalTime}}{{else}}**首次触发时间**: {{timeformat .FirstTriggerTime}}{{end}} \n{{$time_duration := sub now.Unix .FirstTriggerTime }}{{if .IsRecovered}}{{$time_duration = sub .LastEvalTime .FirstTriggerTime }}{{end}}**距离首次告警**: {{humanizeDurationInterface $time_duration}}\n**发送时间**: {{timestamp}}');
INSERT INTO `notify_tpl`(id,channel,name,content) VALUES (3, 'dingtalk', 'dingtalk', '#### {{if .IsRecovered}}<font color=\"#008800\">S{{.Severity}} - Recovered - {{.RuleName}}</font>{{else}}<font color=\"#FF0000\">S{{.Severity}} - Triggered - {{.RuleName}}</font>{{end}}\n\n---\n\n- **规则标题**: {{.RuleName}}{{if .RuleNote}}\n- **规则备注**: {{.RuleNote}}{{end}}\n{{if not .IsRecovered}}- **触发时值**: {{.TriggerValue}}{{end}}\n{{if .TargetIdent}}- **监控对象**: {{.TargetIdent}}{{end}}\n- **监控指标**: {{.TagsJSON}}\n- {{if .IsRecovered}}**恢复时间**: {{timeformat .LastEvalTime}}{{else}}**触发时间**: {{timeformat .TriggerTime}}{{end}}\n- **发送时间**: {{timestamp}}\n ');
INSERT INTO `notify_tpl`(id,channel,name,content) VALUES (4, 'email', 'email', '<!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\n <title>夜莺告警通知</title>\n <style type=\"text/css\">\n .wrapper {\n background-color: #f8f8f8;\n padding: 15px;\n height: 100%;\n }\n .main {\n width: 600px;\n padding: 30px;\n margin: 0 auto;\n background-color: #fff;\n font-size: 12px;\n font-family: verdana,\'Microsoft YaHei\',Consolas,\'Deja Vu Sans Mono\',\'Bitstream Vera Sans Mono\';\n }\n header {\n border-radius: 2px 2px 0 0;\n }\n header .title {\n font-size: 14px;\n color: #333333;\n margin: 0;\n }\n header .sub-desc {\n color: #333;\n font-size: 14px;\n margin-top: 6px;\n margin-bottom: 0;\n }\n hr {\n margin: 20px 0;\n height: 0;\n border: none;\n border-top: 1px solid #e5e5e5;\n }\n em {\n font-weight: 600;\n }\n table {\n margin: 20px 0;\n width: 100%;\n }\n \n table tbody tr{\n font-weight: 200;\n font-size: 12px;\n color: #666;\n height: 32px;\n }\n \n .succ {\n background-color: green;\n color: #fff;\n }\n \n .fail {\n background-color: red;\n color: #fff;\n }\n \n .succ th, .succ td, .fail th, .fail td {\n color: #fff;\n }\n \n table tbody tr th {\n width: 80px;\n text-align: right;\n }\n .text-right {\n text-align: right;\n }\n .body {\n margin-top: 24px;\n }\n .body-text {\n color: #666666;\n -webkit-font-smoothing: antialiased;\n }\n .body-extra {\n -webkit-font-smoothing: antialiased;\n }\n .body-extra.text-right a {\n text-decoration: none;\n color: #333;\n }\n .body-extra.text-right a:hover {\n color: #666;\n }\n .button {\n width: 200px;\n height: 50px;\n margin-top: 20px;\n text-align: center;\n border-radius: 2px;\n background: #2D77EE;\n line-height: 50px;\n font-size: 20px;\n color: #FFFFFF;\n cursor: pointer;\n }\n .button:hover {\n background: rgb(25, 115, 255);\n border-color: rgb(25, 115, 255);\n color: #fff;\n }\n footer {\n margin-top: 10px;\n text-align: right;\n }\n .footer-logo {\n text-align: right;\n }\n .footer-logo-image {\n width: 108px;\n height: 27px;\n margin-right: 10px;\n }\n .copyright {\n margin-top: 10px;\n font-size: 12px;\n text-align: right;\n color: #999;\n -webkit-font-smoothing: antialiased;\n }\n </style>\n </head>\n <body>\n <div class=\"wrapper\">\n <div class=\"main\">\n <header>\n <h3 class=\"title\">{{.RuleName}}</h3>\n <p class=\"sub-desc\"></p>\n </header>\n \n <hr>\n \n <div class=\"body\">\n <table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n <tbody>\n {{if .IsRecovered}}\n <tr class=\"succ\">\n <th>级别状态:</th>\n <td>S{{.Severity}} Recovered</td>\n </tr>\n {{else}}\n <tr class=\"fail\">\n <th>级别状态:</th>\n <td>S{{.Severity}} Triggered</td>\n </tr>\n {{end}}\n \n <tr>\n <th>策略备注:</th>\n <td>{{.RuleNote}}</td>\n </tr>\n <tr>\n <th>设备备注:</th>\n <td>{{.TargetNote}}</td>\n </tr>\n {{if not .IsRecovered}}\n <tr>\n <th>触发时值:</th>\n <td>{{.TriggerValue}}</td>\n </tr>\n {{end}}\n \n {{if .TargetIdent}}\n <tr>\n <th>监控对象:</th>\n <td>{{.TargetIdent}}</td>\n </tr>\n {{end}}\n <tr>\n <th>监控指标:</th>\n <td>{{.TagsJSON}}</td>\n </tr>\n \n {{if .IsRecovered}}\n <tr>\n <th>恢复时间:</th>\n <td>{{timeformat .LastEvalTime}}</td>\n </tr>\n {{else}}\n <tr>\n <th>触发时间:</th>\n <td>\n {{timeformat .TriggerTime}}\n </td>\n </tr>\n {{end}}\n \n <tr>\n <th>发送时间:</th>\n <td>\n {{timestamp}}\n </td>\n </tr>\n </tbody>\n </table>\n \n <hr>\n \n <footer>\n <div class=\"copyright\" style=\"font-style: italic\">\n 报警太多?使用 <a href=\"https://flashcat.cloud/product/flashduty/\" target=\"_blank\">FlashDuty</a> 做告警聚合降噪、排班OnCall!\n </div>\n </footer>\n </div>\n </div>\n </div>\n </body>\n </html>');
INSERT INTO `notify_tpl`(id,channel,name,content) VALUES (5, 'feishu', 'feishu', '级别状态: S{{.Severity}} {{if .IsRecovered}}Recovered{{else}}Triggered{{end}} \n规则名称: {{.RuleName}}{{if .RuleNote}} \n规则备注: {{.RuleNote}}{{end}} \n监控指标: {{.TagsJSON}}\n{{if .IsRecovered}}恢复时间:{{timeformat .LastEvalTime}}{{else}}触发时间: {{timeformat .TriggerTime}}\n触发时值: {{.TriggerValue}}{{end}}\n发送时间: {{timestamp}}');
INSERT INTO `notify_tpl`(id,channel,name,content) VALUES (6, 'feishucard', 'feishucard', '{{ if .IsRecovered }}\n{{- if ne .Cate \"host\"}}\n**告警集群:** {{.Cluster}}{{end}} \n**级别状态:** S{{.Severity}} Recovered \n**告警名称:** {{.RuleName}} \n**恢复时间:** {{timeformat .LastEvalTime}} \n**告警描述:** **服务已恢复** \n{{- else }}\n{{- if ne .Cate \"host\"}} \n**告警集群:** {{.Cluster}}{{end}} \n**级别状态:** S{{.Severity}} Triggered \n**告警名称:** {{.RuleName}} \n**触发时间:** {{timeformat .TriggerTime}} \n**发送时间:** {{timestamp}} \n**触发时值:** {{.TriggerValue}} \n{{if .RuleNote }}**告警描述:** **{{.RuleNote}}**{{end}} \n{{- end -}}');
INSERT INTO `notify_tpl`(id,channel,name,content) VALUES (7, 'mailsubject', 'mailsubject', '{{if .IsRecovered}}Recovered{{else}}Triggered{{end}}: {{.RuleName}} {{.TagsJSON}}');
INSERT INTO `notify_tpl`(id,channel,name,content) VALUES (8, 'mm', 'mm', '级别状态: S{{.Severity}} {{if .IsRecovered}}Recovered{{else}}Triggered{{end}} \n规则名称: {{.RuleName}}{{if .RuleNote}} \n规则备注: {{.RuleNote}}{{end}} \n监控指标: {{.TagsJSON}} \n{{if .IsRecovered}}恢复时间:{{timeformat .LastEvalTime}}{{else}}触发时间: {{timeformat .TriggerTime}} \n触发时值: {{.TriggerValue}}{{end}} \n发送时间: {{timestamp}}');
CREATE TABLE `sso_config` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(191) NOT NULL,
`content` text NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY (`name`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
CREATE TABLE `es_index_pattern` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`datasource_id` bigint NOT NULL DEFAULT 0 COMMENT 'datasource id',
`name` varchar(191) NOT NULL,
`time_field` varchar(128) NOT NULL DEFAULT '@timestamp',
`allow_hide_system_indices` tinyint(1) NOT NULL DEFAULT 0,
`fields_format` varchar(4096) NOT NULL DEFAULT '',
`create_at` bigint NULL DEFAULT 0,
`create_by` varchar(64) NULL DEFAULT '',
`update_at` bigint NULL DEFAULT 0,
`update_by` varchar(64) NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY (`datasource_id`, `name`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
CREATE TABLE `t_xuper` (
`id` varchar(255) NOT NULL COMMENT '主键',
`block_height` bigint NOT NULL COMMENT '区块高度',
`block_hash` varchar(255) NOT NULL COMMENT '区块hash',
`block_tx_count` bigint NOT NULL COMMENT '区块内的交易总数',
`total_tx_count` bigint NOT NULL COMMENT '链上交易总数',
`timestamp` bigint NOT NULL COMMENT '当前区块产生时间',
`chain_name` varchar(255) NOT NULL COMMENT '链名',
`rootnet` varchar(255) NOT NULL COMMENT '网络名',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
CREATE TABLE `t_xuper_day_tx` (
`id` varchar(255) NOT NULL COMMENT '主键',
`block_day` varchar(255) NOT NULL COMMENT '时间 2022-09-01 格式',
`total_tx_count` bigint NOT NULL COMMENT '总交易数',
`day_tx_count` bigint NOT NULL COMMENT '每日交易总数',
`rootnet` varchar(255) NOT NULL COMMENT '网络名',
`chain_name` varchar(255) NOT NULL COMMENT '链名',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4;
CREATE TABLE `t_xuper_node` (
`rootnet` varchar(255) NOT NULL COMMENT '网络名。唯一',
`node` varchar(255) NULL DEFAULT NULL COMMENT 'ip:端口',
PRIMARY KEY (`rootnet`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4;