nightingale1/docker/initsql/a-n9e.sql

529 lines
26 KiB
MySQL
Raw Normal View History

2021-11-28 18:57:49 +08:00
set names utf8mb4;
drop database if exists n9e_v5;
create database n9e_v5;
use n9e_v5;
2022-04-05 09:12:30 +08:00
CREATE TABLE `users` (
2021-11-28 18:57:49 +08:00
`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) comment 'json e.g. {wecom:xx, dingtalk_robot_token:yy}',
`maintainer` tinyint(1) not null default 0,
2021-11-28 18:57:49 +08:00
`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 DEFAULT CHARSET = utf8mb4;
2022-04-05 09:12:30 +08:00
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');
2021-11-28 18:57:49 +08:00
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 DEFAULT CHARSET = 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,
2021-11-28 18:57:49 +08:00
`group_id` bigint unsigned not null,
`user_id` bigint unsigned not null,
KEY (`group_id`),
2022-08-29 11:27:53 +08:00
KEY (`user_id`),
PRIMARY KEY(`id`)
2021-11-28 18:57:49 +08:00
) ENGINE = InnoDB DEFAULT CHARSET = 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` varchar(4096) not null default '',
2021-11-28 18:57:49 +08:00
PRIMARY KEY (`id`),
UNIQUE KEY (`ckey`)
) ENGINE = InnoDB DEFAULT CHARSET = 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 DEFAULT CHARSET = 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,
2021-11-28 18:57:49 +08:00
`role_name` varchar(128) not null,
`operation` varchar(191) not null,
KEY (`role_name`),
2022-08-29 11:27:53 +08:00
KEY (`operation`),
PRIMARY KEY(`id`)
2021-11-28 18:57:49 +08:00
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;
-- Admin is special, who has no concrete operation but can do anything.
2021-12-06 19:20:33 +08:00
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', '/help/version');
insert into `role_operation`(role_name, operation) values('Guest', '/help/contact');
insert into `role_operation`(role_name, operation) values('Standard', '/metric/explorer');
insert into `role_operation`(role_name, operation) values('Standard', '/object/explorer');
2021-12-10 09:44:06 +08:00
insert into `role_operation`(role_name, operation) values('Standard', '/help/version');
insert into `role_operation`(role_name, operation) values('Standard', '/help/contact');
2021-12-06 19:20:33 +08:00
insert into `role_operation`(role_name, operation) values('Standard', '/users');
insert into `role_operation`(role_name, operation) values('Standard', '/user-groups');
2021-12-10 09:44:06 +08:00
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');
2021-12-06 19:20:33 +08:00
insert into `role_operation`(role_name, operation) values('Standard', '/busi-groups');
2021-12-10 09:44:06 +08:00
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');
2021-12-06 19:20:33 +08:00
insert into `role_operation`(role_name, operation) values('Standard', '/targets');
2021-12-10 09:44:06 +08:00
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');
2021-12-06 19:20:33 +08:00
insert into `role_operation`(role_name, operation) values('Standard', '/alert-rules');
2021-12-10 09:44:06 +08:00
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');
2021-12-06 19:20:33 +08:00
insert into `role_operation`(role_name, operation) values('Standard', '/alert-mutes');
2021-12-10 09:44:06 +08:00
insert into `role_operation`(role_name, operation) values('Standard', '/alert-mutes/add');
insert into `role_operation`(role_name, operation) values('Standard', '/alert-mutes/del');
2021-12-06 19:20:33 +08:00
insert into `role_operation`(role_name, operation) values('Standard', '/alert-subscribes');
2021-12-10 09:44:06 +08:00
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');
2021-12-06 19:20:33 +08:00
insert into `role_operation`(role_name, operation) values('Standard', '/alert-cur-events');
2021-12-10 09:44:06 +08:00
insert into `role_operation`(role_name, operation) values('Standard', '/alert-cur-events/del');
2021-12-06 19:20:33 +08:00
insert into `role_operation`(role_name, operation) values('Standard', '/alert-his-events');
2021-12-06 19:23:43 +08:00
insert into `role_operation`(role_name, operation) values('Standard', '/job-tpls');
2021-12-10 09:44:06 +08:00
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');
2021-12-06 19:23:43 +08:00
insert into `role_operation`(role_name, operation) values('Standard', '/job-tasks');
2021-12-10 09:44:06 +08:00
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');
2021-11-28 18:57:49 +08:00
-- for alert_rule | collect_rule | mute | dashboard grouping
CREATE TABLE `busi_group` (
`id` bigint unsigned not null auto_increment,
`name` varchar(191) not null,
2022-03-21 11:44:51 +08:00
`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',
2021-11-28 18:57:49 +08:00
`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 DEFAULT CHARSET = utf8mb4;
2021-12-04 16:53:20 +08:00
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');
2021-11-28 18:57:49 +08:00
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 DEFAULT CHARSET = 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,
`tags` varchar(255) not null comment 'split by space',
`public` 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`)
) ENGINE = InnoDB DEFAULT CHARSET = 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 DEFAULT CHARSET = utf8mb4;
-- deprecated
2021-11-28 18:57:49 +08:00
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',
2021-12-24 20:03:53 +08:00
`configs` varchar(8192) comment 'dashboard variables',
2021-11-28 18:57:49 +08:00
`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 DEFAULT CHARSET = utf8mb4;
-- deprecated
2021-11-28 18:57:49 +08:00
-- 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 DEFAULT CHARSET = utf8mb4;
-- deprecated
2021-11-28 18:57:49 +08:00
CREATE TABLE `chart` (
`id` bigint unsigned not null auto_increment,
`group_id` bigint unsigned not null comment 'chart group id',
2022-03-17 18:57:57 +08:00
`configs` text,
2021-11-28 18:57:49 +08:00
`weight` int not null default 0,
PRIMARY KEY (`id`),
KEY (`group_id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;
CREATE TABLE `chart_share` (
`id` bigint unsigned not null auto_increment,
`cluster` varchar(128) not null,
2021-12-24 20:03:53 +08:00
`configs` text,
2021-11-28 18:57:49 +08:00
`create_at` bigint not null default 0,
`create_by` varchar(64) not null default '',
primary key (`id`),
key (`create_at`)
) ENGINE = InnoDB DEFAULT CHARSET = 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,
2021-11-28 18:57:49 +08:00
`cluster` 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,
2022-05-31 13:08:09 +08:00
`severity` tinyint(1) not null comment '1:Emergency 2:Warning 3:Notice',
2021-11-28 18:57:49 +08:00
`disabled` tinyint(1) not null comment '0:enabled 1:disabled',
`prom_for_duration` int not null comment 'prometheus for, unit:s',
2022-06-02 11:07:31 +08:00
`prom_ql` text not null comment 'promql',
2021-11-28 18:57:49 +08:00
`prom_eval_interval` int not null comment 'evaluate interval',
`enable_stime` char(5) not null default '00:00',
`enable_etime` char(5) not null default '23:59',
`enable_days_of_week` varchar(32) not null default '' comment 'split by space: 0 1 2 3 4 5 6',
2022-01-08 17:52:29 +08:00
`enable_in_bg` tinyint(1) not null default 0 comment '1: only this bg 0: global',
2021-11-28 18:57:49 +08:00
`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',
2022-06-10 16:26:53 +08:00
`notify_max_number` int not null default 0 comment '',
2022-01-26 08:59:30 +08:00
`recover_duration` int not null default 0 comment 'unit: s',
2021-11-28 18:57:49 +08:00
`callbacks` varchar(255) 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',
`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',
2022-06-02 11:07:31 +08:00
`prod` varchar(255) not null default '',
`note` varchar(1024) not null default '',
`cate` varchar(128) not null,
2021-11-28 18:57:49 +08:00
`cluster` varchar(128) not null,
2021-12-24 20:03:53 +08:00
`tags` varchar(4096) not null default '' comment 'json,map,tagkey->regexp|value',
2021-11-28 18:57:49 +08:00
`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',
2021-11-28 18:57:49 +08:00
`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 '',
2021-11-28 18:57:49 +08:00
PRIMARY KEY (`id`),
KEY (`create_at`),
KEY (`group_id`)
) ENGINE = InnoDB DEFAULT CHARSET = 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',
2021-11-28 18:57:49 +08:00
`group_id` bigint not null default 0 comment 'busi group id',
`cate` varchar(128) not null,
2021-11-28 18:57:49 +08:00
`cluster` varchar(128) not null,
`rule_id` bigint not null default 0,
2021-12-24 20:03:53 +08:00
`tags` varchar(4096) not null default '' comment 'json,map,tagkey->regexp|value',
2021-11-28 18:57:49 +08:00
`redefine_severity` tinyint(1) default 0 comment 'is redefine severity?',
`new_severity` tinyint(1) not null comment '0:Emergency 1:Warning 2:Notice',
`redefine_channels` tinyint(1) 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',
`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 (`update_at`),
KEY (`group_id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;
CREATE TABLE `target` (
`id` bigint unsigned not null auto_increment,
`group_id` bigint not null default 0 comment 'busi group id',
`cluster` varchar(128) not null comment 'append to alert event as field',
`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,
PRIMARY KEY (`id`),
UNIQUE KEY (`ident`),
KEY (`group_id`)
) ENGINE = InnoDB DEFAULT CHARSET = 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;
2022-03-27 19:06:31 +08:00
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`)
2022-03-27 19:06:31 +08:00
) ENGINE=InnoDB DEFAULT CHARSET = utf8mb4;
2022-04-08 10:11:55 +08:00
insert into metric_view(name, cate, configs) values('Host View', 0, '{"filters":[{"oper":"=","label":"__name__","value":"cpu_usage_idle"}],"dynamicLabels":[],"dimensionLabels":[{"label":"ident","value":""}]}');
2022-04-06 19:04:02 +08:00
CREATE TABLE `recording_rule` (
`id` bigint unsigned not null auto_increment,
`group_id` bigint not null default '0' comment 'group_id',
`cluster` 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) default '' comment 'split by space: service=n9e mod=api',
`create_at` bigint default '0',
`create_by` varchar(64) default '',
`update_at` bigint default '0',
`update_by` varchar(64) default '',
PRIMARY KEY (`id`),
KEY `group_id` (`group_id`),
KEY `update_at` (`update_at`)
) ENGINE=InnoDB DEFAULT CHARSET = utf8mb4;
2022-03-22 11:19:06 +08:00
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,
2022-03-27 19:06:31 +08:00
`create_by` bigint not null default 0 comment 'user id',
2022-03-22 11:19:06 +08:00
`update_at` bigint not null default 0,
PRIMARY KEY (`id`),
KEY (`create_by`)
2022-03-22 11:19:06 +08:00
) ENGINE=InnoDB DEFAULT CHARSET = utf8mb4;
2022-04-08 10:11:55 +08:00
insert into alert_aggr_view(name, rule, cate) values('By BusiGroup, Severity', 'field:group_name::field:severity', 0);
2022-04-08 11:43:11 +08:00
insert into alert_aggr_view(name, rule, cate) values('By RuleName', 'field:rule_name', 0);
2022-03-22 11:19:06 +08:00
2021-11-28 18:57:49 +08:00
CREATE TABLE `alert_cur_event` (
`id` bigint unsigned not null comment 'use alert_his_event.id',
`cate` varchar(128) not null,
2021-11-28 18:57:49 +08:00
`cluster` varchar(128) not null,
`group_id` bigint unsigned not null comment 'busi group id of rule',
2022-03-21 17:35:10 +08:00
`group_name` varchar(255) not null default '' comment 'busi group name',
2021-11-28 18:57:49 +08:00
`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 '',
2021-11-28 18:57:49 +08:00
`severity` tinyint(1) not null comment '0:Emergency 1:Warning 2:Notice',
`prom_for_duration` int not null comment 'prometheus for, unit:s',
2021-12-24 20:03:53 +08:00
`prom_ql` varchar(8192) not null comment 'promql',
2021-11-28 18:57:49 +08:00
`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),
`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 comment '',
2021-11-28 18:57:49 +08:00
`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,
2021-11-28 18:57:49 +08:00
`trigger_time` bigint not null,
`trigger_value` varchar(255) not null,
`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 DEFAULT CHARSET = utf8mb4;
CREATE TABLE `alert_his_event` (
`id` bigint unsigned not null AUTO_INCREMENT,
`is_recovered` tinyint(1) not null,
`cate` varchar(128) not null,
2021-11-28 18:57:49 +08:00
`cluster` varchar(128) not null,
`group_id` bigint unsigned not null comment 'busi group id of rule',
2022-03-21 17:35:10 +08:00
`group_name` varchar(255) not null default '' comment 'busi group name',
2021-11-28 18:57:49 +08:00
`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 '',
2021-11-28 18:57:49 +08:00
`severity` tinyint(1) not null comment '0:Emergency 1:Warning 2:Notice',
`prom_for_duration` int not null comment 'prometheus for, unit:s',
2021-12-24 20:03:53 +08:00
`prom_ql` varchar(8192) not null comment 'promql',
2021-11-28 18:57:49 +08:00
`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),
`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 comment '',
2021-11-28 18:57:49 +08:00
`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,
2021-11-28 18:57:49 +08:00
`trigger_time` bigint not null,
`trigger_value` varchar(255) not null,
2021-12-08 00:07:25 +08:00
`recover_time` bigint not null default 0,
`last_eval_time` bigint not null default 0 comment 'for time filter',
2021-11-28 18:57:49 +08:00
`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`)
) ENGINE=InnoDB DEFAULT CHARSET = 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 DEFAULT CHARSET = 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 DEFAULT CHARSET = utf8mb4;
CREATE TABLE `task_record`
(
`id` bigint unsigned not null comment 'ibex task 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`)
) ENGINE = InnoDB DEFAULT CHARSET = 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',
`cluster` varchar(128) not null default '' comment 'target reader cluster',
`clock` bigint not null,
PRIMARY KEY (`id`),
UNIQUE KEY (`instance`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;