feat(告警模块): 其他类型的告警,每个场景联动产生一条告警记录。告警日志添加告警说明 (#441)

This commit is contained in:
tancong 2023-11-13 19:03:40 +08:00 committed by GitHub
parent d9603381e0
commit 47975b0da2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 3 deletions

View File

@ -9,6 +9,7 @@ public interface AlarmConstants {
String alarmName = "alarmName";
String level = "level";
String ownerId = "ownerId";
String description = "description";
String state = "state";
String alarmTime = "alarmTime";
String lastAlarmTime = "lastAlarmTime";

View File

@ -55,6 +55,9 @@ public interface AlarmRuleHandler {
@Schema(description = "告警名称")
private String alarmName;
@Schema(description = "告警说明")
private String description;
@Schema(description = "是否重复告警")
private boolean alarming;

View File

@ -64,7 +64,8 @@ public class DefaultAlarmRuleHandler implements AlarmRuleHandler, CommandLineRun
AlarmConstants.ConfigKey.level,
AlarmConstants.ConfigKey.targetType,
AlarmConstants.ConfigKey.state,
AlarmConstants.ConfigKey.ownerId
AlarmConstants.ConfigKey.ownerId,
AlarmConstants.ConfigKey.description
));
private final Map<Tuple2<String, Integer>, Set<String>> ruleAlarmBinds = new ConcurrentHashMap<>();
@ -159,6 +160,7 @@ public class DefaultAlarmRuleHandler implements AlarmRuleHandler, CommandLineRun
entity.setSourceId(result.getSourceId());
entity.setAlarmName(result.getAlarmName());
entity.setDescription(result.getDescription());
entity.generateId();
return entity;
}
@ -280,6 +282,7 @@ public class DefaultAlarmRuleHandler implements AlarmRuleHandler, CommandLineRun
info.setId(IDGenerator.RANDOM.generate());
info.setAlarmConfigId(record.getAlarmConfigId());
info.setAlarmConfigName(record.getAlarmName());
info.setDescription(record.getDescription());
info.setAlarmRecordId(record.getId());
info.setLevel(record.getLevel());
info.setAlarmTime(record.getAlarmTime());

View File

@ -21,7 +21,7 @@ public class OtherAlarmTarget implements AlarmTarget {
@Override
public Flux<AlarmTargetInfo> convert(AlarmData data) {
return Flux.just(AlarmTargetInfo
.of(data.getAlarmConfigId(),
.of(data.getRuleId(),
data.getRuleName(),
getType()));
}

View File

@ -105,7 +105,7 @@ public class AlarmConfigEntity extends GenericEntity<String> implements RecordCr
configs.put(AlarmConstants.ConfigKey.ownerId, getModifierId() == null ? getCreatorId() : getModifierId());
configs.put(AlarmConstants.ConfigKey.targetType, getTargetType());
configs.put(AlarmConstants.ConfigKey.state, getState().name());
configs.put(AlarmConstants.ConfigKey.description, getDescription());
return configs;
}
}