schema.sql 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. use hertzbeat;
  2. -- ----------------------------
  3. -- Table structure for monitor
  4. -- ----------------------------
  5. DROP TABLE IF EXISTS monitor ;
  6. CREATE TABLE monitor
  7. (
  8. id bigint not null auto_increment comment '监控ID',
  9. job_id bigint not null comment '监控对应下发的任务ID',
  10. name varchar(100) not null comment '监控的名称',
  11. app varchar(100) not null comment '监控的类型:linux,mysql,jvm...',
  12. host varchar(100) not null comment '监控的对端host:ipv4,ipv6,域名',
  13. intervals int not null default 600 comment '监控的采集间隔时间,单位秒',
  14. status tinyint not null default 1 comment '监控状态 0:未监控,1:可用,2:不可用,3:不可达',
  15. description varchar(255) comment '描述备注信息',
  16. creator varchar(100) comment '创建者',
  17. modifier varchar(100) comment '最新修改者',
  18. gmt_create timestamp default current_timestamp comment 'create time',
  19. gmt_update datetime default current_timestamp on update current_timestamp comment 'update time',
  20. primary key (id),
  21. index query_index (app, host, name)
  22. ) ENGINE = InnoDB DEFAULT CHARSET=utf8mb4;
  23. -- ----------------------------
  24. -- Table structure for param
  25. -- ----------------------------
  26. DROP TABLE IF EXISTS param ;
  27. CREATE TABLE param
  28. (
  29. id bigint not null auto_increment comment '参数ID',
  30. monitor_id bigint not null comment '监控ID',
  31. field varchar(100) not null comment '参数标识符',
  32. value varchar(255) comment '参数值,最大字符长度255',
  33. type tinyint not null default 0 comment '参数类型 0:数字 1:字符串 2:加密串',
  34. gmt_create timestamp default current_timestamp comment 'create time',
  35. gmt_update datetime default current_timestamp on update current_timestamp comment 'update time',
  36. primary key (id),
  37. index monitor_id (monitor_id),
  38. unique key unique_param (monitor_id, field)
  39. ) ENGINE = InnoDB DEFAULT CHARSET=utf8mb4;
  40. -- ----------------------------
  41. -- Table structure for param
  42. -- ----------------------------
  43. DROP TABLE IF EXISTS param_define ;
  44. CREATE TABLE param_define
  45. (
  46. id bigint not null auto_increment comment '参数ID',
  47. app varchar(100) not null comment '监控的类型:linux,mysql,jvm...',
  48. name varchar(100) not null comment '参数字段对外显示名称',
  49. field varchar(100) not null comment '参数字段标识符',
  50. type varchar(20) not null default 'text' comment '字段类型,样式(大部分映射input标签type属性)',
  51. required boolean not null default false comment '是否是必输项 true-必填 false-可选',
  52. param_range varchar(100) not null comment '当type为number时,用range表示范围 eg: 0-233',
  53. param_limit tinyint unsigned not null comment '当type为text时,用limit表示字符串限制大小.最大255',
  54. param_option varchar(255) not null comment '当type为radio单选框,checkbox复选框时,option表示可选项值列表',
  55. creator varchar(100) comment '创建者',
  56. modifier varchar(100) comment '最新修改者',
  57. gmt_create timestamp default current_timestamp comment 'create time',
  58. gmt_update datetime default current_timestamp on update current_timestamp comment 'update time',
  59. primary key (id),
  60. unique key unique_param_define (app, field)
  61. ) ENGINE = InnoDB DEFAULT CHARSET=utf8mb4;
  62. -- ----------------------------
  63. -- Table structure for alert_define
  64. -- ----------------------------
  65. DROP TABLE IF EXISTS alert_define ;
  66. CREATE TABLE alert_define
  67. (
  68. id bigint not null auto_increment comment '告警定义ID',
  69. app varchar(100) not null comment '配置告警的监控类型:linux,mysql,jvm...',
  70. metric varchar(100) not null comment '配置告警的指标集合:cpu,memory,info...',
  71. field varchar(100) not null comment '配置告警的指标:usage,cores...',
  72. preset boolean not null default false comment '是否是全局默认告警,是则所有此类型监控默认关联此告警',
  73. expr varchar(255) not null comment '告警触发条件表达式',
  74. priority tinyint not null default 0 comment '告警级别 0:高-emergency-紧急告警-红色 1:中-critical-严重告警-橙色 2:低-warning-警告告警-黄色',
  75. times int not null default 1 comment '触发次数,即达到触发阈值次数要求后才算触发告警',
  76. enable boolean not null default true comment '告警阈值开关',
  77. template varchar(255) not null comment '告警通知模板内容',
  78. creator varchar(100) comment '创建者',
  79. modifier varchar(100) comment '最新修改者',
  80. gmt_create timestamp default current_timestamp comment 'create time',
  81. gmt_update datetime default current_timestamp on update current_timestamp comment 'update time',
  82. primary key (id)
  83. ) ENGINE = InnoDB DEFAULT CHARSET=utf8mb4;
  84. -- ----------------------------
  85. -- Table structure for alert_define_monitor_bind
  86. -- ----------------------------
  87. DROP TABLE IF EXISTS alert_define_monitor_bind ;
  88. CREATE TABLE alert_define_monitor_bind
  89. (
  90. id bigint not null auto_increment comment '告警定义与监控关联ID',
  91. alert_define_id bigint not null comment '告警定义ID',
  92. monitor_id bigint not null comment '监控ID',
  93. gmt_create timestamp default current_timestamp comment 'create time',
  94. gmt_update datetime default current_timestamp on update current_timestamp comment 'update time',
  95. primary key (id),
  96. index index_bind (alert_define_id, monitor_id)
  97. ) ENGINE = InnoDB DEFAULT CHARSET=utf8mb4;
  98. -- ----------------------------
  99. -- Table structure for alert
  100. -- ----------------------------
  101. DROP TABLE IF EXISTS alert ;
  102. CREATE TABLE alert
  103. (
  104. id bigint not null auto_increment comment '告警ID',
  105. target varchar(255) not null comment '告警目标对象: 监控可用性-available 指标-app.metrics.field',
  106. monitor_id bigint not null comment '告警对象关联的监控ID',
  107. monitor_name varchar(100) comment '告警对象关联的监控名称',
  108. alert_define_id bigint comment '告警关联的告警定义ID',
  109. priority tinyint not null default 0 comment '告警级别 0:高-emergency-紧急告警-红色 1:中-critical-严重告警-橙色 2:低-warning-警告告警-黄色',
  110. content varchar(255) not null comment '告警通知实际内容',
  111. status tinyint not null default 0 comment '告警状态: 0-正常告警(待处理) 1-阈值触发但未达到告警次数 2-恢复告警 3-已处理',
  112. times int not null comment '触发次数,即达到告警定义的触发阈值次数要求后才会发告警',
  113. gmt_create timestamp default current_timestamp comment 'create time',
  114. primary key (id)
  115. ) ENGINE = InnoDB DEFAULT CHARSET=utf8mb4;
  116. -- ----------------------------
  117. -- Table structure for notice_rule
  118. -- ----------------------------
  119. DROP TABLE IF EXISTS notice_rule ;
  120. CREATE TABLE notice_rule
  121. (
  122. id bigint not null auto_increment comment '通知策略主键索引ID',
  123. name varchar(100) not null comment '策略名称',
  124. receiver_id bigint not null comment '消息接收人ID',
  125. receiver_name varchar(100) not null comment '消息接收人标识',
  126. enable boolean not null default true comment '是否启用此策略',
  127. filter_all boolean not null default true comment '是否转发所有',
  128. creator varchar(100) comment '创建者',
  129. modifier varchar(100) comment '最新修改者',
  130. gmt_create timestamp default current_timestamp comment 'create time',
  131. gmt_update datetime default current_timestamp on update current_timestamp comment 'update time',
  132. primary key (id)
  133. ) ENGINE = InnoDB DEFAULT CHARSET=utf8mb4;
  134. -- ----------------------------
  135. -- Table structure for notice_receiver
  136. -- ----------------------------
  137. DROP TABLE IF EXISTS notice_receiver ;
  138. CREATE TABLE notice_receiver
  139. (
  140. id bigint not null auto_increment comment '消息接收人ID',
  141. name varchar(100) not null comment '消息接收人姓名',
  142. type tinyint not null comment '通知信息方式: 0-手机短信 1-邮箱 2-webhook 3-微信公众号 4-企业微信机器人 5-钉钉机器人',
  143. phone varchar(100) comment '手机号, 通知方式为手机短信时有效',
  144. email varchar(100) comment '邮箱账号, 通知方式为邮箱时有效',
  145. hook_url varchar(255) comment 'URL地址, 通知方式为webhook有效',
  146. wechat_id varchar(255) comment 'openId, 通知方式为微信公众号或企业微信机器人有效',
  147. access_token varchar(255) comment '访问token, 通知方式为钉钉机器人有效',
  148. creator varchar(100) comment '创建者',
  149. modifier varchar(100) comment '最新修改者',
  150. gmt_create timestamp default current_timestamp comment 'create time',
  151. gmt_update datetime default current_timestamp on update current_timestamp comment 'update time',
  152. primary key (id)
  153. ) ENGINE = InnoDB DEFAULT CHARSET=utf8mb4;
  154. COMMIT;