[monitor] 告警结构duration持续时间变更为times触发次数
This commit is contained in:
@@ -72,7 +72,7 @@ public class CalculateAlarm {
|
||||
.monitorId(monitorId)
|
||||
.priority((byte) 0)
|
||||
.status((byte) 0)
|
||||
.duration(300);
|
||||
.times(1);
|
||||
if (metricsData.getCode() == CollectRep.Code.UN_REACHABLE) {
|
||||
// UN_REACHABLE 对端不可达(网络层icmp)
|
||||
alertBuilder.target(CommonConstants.REACHABLE)
|
||||
@@ -139,7 +139,7 @@ public class CalculateAlarm {
|
||||
.priority(define.getPriority())
|
||||
.status((byte) 0)
|
||||
.target(app + "." + metrics + "." + define.getField())
|
||||
.duration(define.getDuration())
|
||||
.times(1)
|
||||
// 模板中关键字匹配替换
|
||||
.content(AlertTemplateUtil.render(define.getTemplate(), fieldValueMap))
|
||||
.build();
|
||||
|
||||
@@ -41,42 +41,44 @@ public class Alert {
|
||||
@ApiModelProperty(value = "告警记录实体主键索引ID", example = "87584674384", accessMode = READ_ONLY, position = 0)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "告警监控对象ID", example = "87432674336", accessMode = READ_WRITE, position = 1)
|
||||
@ApiModelProperty(value = "告警目标对象: 监控可用性-available 指标-app.metrics.field",
|
||||
example = "1", accessMode = READ_WRITE, position = 1)
|
||||
@Length(max = 255)
|
||||
private String target;
|
||||
|
||||
@ApiModelProperty(value = "告警对象关联的监控ID", example = "87432674336", accessMode = READ_WRITE, position = 2)
|
||||
private Long monitorId;
|
||||
|
||||
@ApiModelProperty(value = "告警监控对象名称", example = "87432674336", accessMode = READ_WRITE, position = 2)
|
||||
@ApiModelProperty(value = "告警对象关联的监控名称", example = "Linux_192.132.23.1",
|
||||
accessMode = READ_WRITE, position = 3)
|
||||
private String monitorName;
|
||||
|
||||
@ApiModelProperty(value = "告警关联的告警定义ID", example = "8743267443543", accessMode = READ_WRITE, position = 4)
|
||||
private Long alertDefineId;
|
||||
|
||||
@ApiModelProperty(value = "告警级别 0:高-emergency-紧急告警-红色 1:中-critical-严重告警-橙色 2:低-warning-警告告警-黄色",
|
||||
example = "1", accessMode = READ_WRITE, position = 3)
|
||||
example = "1", accessMode = READ_WRITE, position = 5)
|
||||
@Min(0)
|
||||
@Max(2)
|
||||
private byte priority;
|
||||
|
||||
@ApiModelProperty(value = "告警通知实际内容", example = "linux_192.134.32.1: 534543534 cpu usage high",
|
||||
accessMode = READ_WRITE, position = 6)
|
||||
@Length(max = 1024)
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty(value = "告警状态: 0-待发送 1-已发送 2-已过期(已经超过持续时间)",
|
||||
example = "1", accessMode = READ_WRITE, position = 4)
|
||||
example = "1", accessMode = READ_WRITE, position = 7)
|
||||
@Min(0)
|
||||
@Max(2)
|
||||
private byte status;
|
||||
|
||||
@ApiModelProperty(value = "告警目标对象: 监控可用性-available 指标-app.metrics.field",
|
||||
example = "1", accessMode = READ_WRITE, position = 4)
|
||||
@Length(max = 255)
|
||||
private String target;
|
||||
|
||||
@ApiModelProperty(value = "触发告警后持续时间,单位s", example = "60", accessMode = READ_WRITE, position = 7)
|
||||
@ApiModelProperty(value = "告警阈值触发次数", example = "3", accessMode = READ_WRITE, position = 8)
|
||||
@Min(0)
|
||||
private int duration;
|
||||
@Max(10)
|
||||
private int times;
|
||||
|
||||
@ApiModelProperty(value = "告警通知实际内容", example = "linux_192.134.32.1: 534543534 cpu usage high",
|
||||
accessMode = READ_WRITE, position = 10)
|
||||
@Length(max = 1024)
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 记录创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "记录创建时间(毫秒时间戳)", example = "1612198922000", accessMode = READ_ONLY, position = 13)
|
||||
@ApiModelProperty(value = "告警触发时间(毫秒时间戳)", example = "1612198922000", accessMode = READ_ONLY, position = 9)
|
||||
@Column(insertable = false, updatable = false)
|
||||
private LocalDateTime gmtCreate;
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public class AlertDefine {
|
||||
@NotNull
|
||||
private String field;
|
||||
|
||||
@ApiModelProperty(value = "是否是默认预置告警", example = "false", accessMode = READ_WRITE, position = 4)
|
||||
@ApiModelProperty(value = "是否是全局默认告警", example = "false", accessMode = READ_WRITE, position = 4)
|
||||
private boolean preset;
|
||||
|
||||
@ApiModelProperty(value = "告警阈值触发条件表达式", example = "usage>90", accessMode = READ_WRITE, position = 5)
|
||||
@@ -70,9 +70,10 @@ public class AlertDefine {
|
||||
@Max(2)
|
||||
private byte priority;
|
||||
|
||||
@ApiModelProperty(value = "触发告警后持续时间,单位s", example = "60", accessMode = READ_WRITE, position = 7)
|
||||
@ApiModelProperty(value = "阈值触发次数,即达到次数要求后才触发告警", example = "3", accessMode = READ_WRITE, position = 7)
|
||||
@Min(0)
|
||||
private int duration;
|
||||
@Max(10)
|
||||
private int times;
|
||||
|
||||
@ApiModelProperty(value = "告警阈值开关", example = "true", accessMode = READ_WRITE, position = 8)
|
||||
private boolean enable = true;
|
||||
|
||||
@@ -74,10 +74,10 @@ CREATE TABLE alert_define
|
||||
app varchar(100) not null comment '配置告警的监控类型:linux,mysql,jvm...',
|
||||
metric varchar(100) not null comment '配置告警的指标集合:cpu,memory,info...',
|
||||
field varchar(100) not null comment '配置告警的指标:usage,cores...',
|
||||
preset boolean not null default false comment '是否是默认预置告警,是则新增监控默认关联此告警',
|
||||
preset boolean not null default false comment '是否是全局默认告警,是则所有此类型监控默认关联此告警',
|
||||
expr varchar(255) not null comment '告警触发条件表达式',
|
||||
priority tinyint not null default 0 comment '告警级别 0:高-emergency-紧急告警-红色 1:中-critical-严重告警-橙色 2:低-warning-警告告警-黄色',
|
||||
duration int not null comment '触发告警后持续时间,单位s',
|
||||
times int not null default 1 comment '触发次数,即达到触发阈值次数要求后才算触发告警',
|
||||
enable boolean not null default true comment '告警阈值开关',
|
||||
template varchar(255) not null comment '告警通知模板内容',
|
||||
creator varchar(100) comment '创建者',
|
||||
@@ -110,13 +110,14 @@ DROP TABLE IF EXISTS alert ;
|
||||
CREATE TABLE alert
|
||||
(
|
||||
id bigint not null auto_increment comment '告警ID',
|
||||
monitor_id bigint not null comment '告警监控对象ID',
|
||||
monitor_name varchar(100) comment '告警监控对象名称',
|
||||
priority tinyint not null default 0 comment '告警级别 0:高-emergency-紧急告警-红色 1:中-critical-严重告警-橙色 2:低-warning-警告告警-黄色',
|
||||
status tinyint not null default 0 comment '告警状态: 0-待发送 1-已发送 2-已过期(已经超过持续时间)',
|
||||
target varchar(255) not null comment '告警目标对象: 监控可用性-available 指标-app.metrics.field',
|
||||
duration int not null comment '触发告警后持续时间,单位s',
|
||||
monitor_id bigint not null comment '告警对象关联的监控ID',
|
||||
monitor_name varchar(100) comment '告警对象关联的监控名称',
|
||||
alert_define_id bigint not null comment '告警关联的告警定义ID',
|
||||
priority tinyint not null default 0 comment '告警级别 0:高-emergency-紧急告警-红色 1:中-critical-严重告警-橙色 2:低-warning-警告告警-黄色',
|
||||
content varchar(255) not null comment '告警通知实际内容',
|
||||
status tinyint not null default 0 comment '告警状态: 0-待发送 1-已发送 2-已过期(已经超过持续时间)',
|
||||
times int not null comment '触发次数,即达到告警定义的触发阈值次数要求后才会发告警',
|
||||
gmt_create timestamp default current_timestamp comment 'create time',
|
||||
primary key (id)
|
||||
) ENGINE = InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
@@ -6,6 +6,6 @@ export class Alert {
|
||||
priority: number = 2;
|
||||
status!: number;
|
||||
content!: string;
|
||||
duration!: number;
|
||||
times!: number;
|
||||
gmtCreate!: number;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ export class AlertDefine {
|
||||
expr!: string;
|
||||
// 告警级别 0:高-emergency-紧急告警-红色 1:中-critical-严重告警-橙色 2:低-warning-警告告警-黄色
|
||||
priority: number = 2;
|
||||
duration: number = 600;
|
||||
times: number = 3;
|
||||
enable: boolean = true;
|
||||
template!: string;
|
||||
creator!: string;
|
||||
|
||||
@@ -34,12 +34,11 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th nzAlign="center" nzLeft nzWidth="60px" [(nzChecked)]="checkedAll" (nzCheckedChange)="onAllChecked($event)"></th>
|
||||
<th nzAlign="center">告警对象</th>
|
||||
<th nzAlign="center">告警指标</th>
|
||||
<th nzAlign="center">所属监控</th>
|
||||
<th nzAlign="center">级别</th>
|
||||
<th nzAlign="center">告警内容</th>
|
||||
<th nzAlign="center">触发时间</th>
|
||||
<th nzAlign="center">持续时间</th>
|
||||
<th nzAlign="center">告警时间</th>
|
||||
<th nzAlign="center" nzRight>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -68,7 +67,6 @@
|
||||
</td>
|
||||
<td nzAlign="center">{{ data.content }}</td>
|
||||
<td nzAlign="center">{{ data.gmtCreate }}</td>
|
||||
<td nzAlign="center">{{ data.duration }}</td>
|
||||
<td nzAlign="center" nzRight>
|
||||
<button nz-button nzType="primary" (click)="onRestoreOneAlert(data.id)">
|
||||
<i nz-icon nzType="up-circle" nzTheme="outline"></i>
|
||||
|
||||
@@ -41,9 +41,9 @@
|
||||
<th nzAlign="center">指标对象</th>
|
||||
<th nzAlign="center">阈值触发表达式</th>
|
||||
<th nzAlign="center">告警级别</th>
|
||||
<th nzAlign="center">持续时间</th>
|
||||
<th nzAlign="center">触发次数</th>
|
||||
<th nzAlign="center">通知模版</th>
|
||||
<th nzAlign="center">预置默认</th>
|
||||
<th nzAlign="center">全局默认</th>
|
||||
<th nzAlign="center">最新修改时间</th>
|
||||
<th nzAlign="center" nzRight>操作</th>
|
||||
</tr>
|
||||
@@ -71,7 +71,7 @@
|
||||
<span>警告告警</span>
|
||||
</nz-tag>
|
||||
</td>
|
||||
<td nzAlign="center">{{ data.duration + 's' }}</td>
|
||||
<td nzAlign="center">{{ data.times }}</td>
|
||||
<td nzAlign="center">{{ data.template }}</td>
|
||||
<td nzAlign="center">
|
||||
<nz-tag *ngIf="data.preset" nzColor="green">
|
||||
@@ -149,10 +149,10 @@
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
<nz-form-item>
|
||||
<nz-form-label nzSpan="7" nzRequired="true" nzFor= "duration">持续时间</nz-form-label>
|
||||
<nz-form-label nzSpan="7" nzRequired="true" nzFor= "duration">触发次数</nz-form-label>
|
||||
<nz-form-control nzSpan="8">
|
||||
<nz-input-number [(ngModel)]="define.duration" [nzMin]="10" [nzMax]="10000" [nzStep]="10"
|
||||
name="duration" id="duration" nzPlaceHolder="请输入告警的持续时间">
|
||||
<nz-input-number [(ngModel)]="define.times" [nzMin]="1" [nzMax]="10" [nzStep]="1"
|
||||
name="duration" id="duration" nzPlaceHolder="触发几次后告警">
|
||||
</nz-input-number>
|
||||
</nz-form-control>
|
||||
</nz-form-item >
|
||||
@@ -167,7 +167,7 @@
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
<nz-form-item>
|
||||
<nz-form-label nzSpan="7" nzRequired="true" nzFor= "preset">默认预置</nz-form-label>
|
||||
<nz-form-label nzSpan="7" nzRequired="true" nzFor= "preset">全局默认</nz-form-label>
|
||||
<nz-form-control nzSpan="8">
|
||||
<nz-switch [(ngModel)]="define.preset" name="preset" id="preset"></nz-switch>
|
||||
</nz-form-control>
|
||||
|
||||
Reference in New Issue
Block a user