提交 3470b1d5 authored 作者: Edwin's avatar Edwin

feat: enhance alarm message filtering by normalizing endpoint paths and…

feat: enhance alarm message filtering by normalizing endpoint paths and improving service name resolution
上级 a42acfa4
......@@ -133,17 +133,21 @@ public class AlarmServiceImpl implements AlarmService {
}
private boolean shouldSkip(AlarmMessage alarmMessage) {
String scope = alarmMessage.getScope();
String name = alarmMessage.getName();
if (StringUtil.isBlank(name)) {
return false;
String rawMessage = alarmMessage.getAlarmMessage();
if (rawMessage == null) {
rawMessage = "";
}
if (SERVICE.equals(scope)) {
return splitToSet(projProperties.getNotNotifyService()).contains(name);
String serviceName = resolveServiceName(alarmMessage, rawMessage);
if (!StringUtil.isBlank(serviceName)
&& splitToSet(projProperties.getNotNotifyService()).contains(serviceName)) {
log.info("Skip alarm for blocked service: {}", serviceName);
return true;
}
if (ENDPOINT_RELATION.equalsIgnoreCase(scope)) {
String pathUrl = extractPathUrl(name);
return !StringUtil.isBlank(pathUrl) && splitToSet(projProperties.getNotNotifyUrl()).contains(pathUrl);
String endpointPath = normalizeEndpointPath(resolveEndpointPath(alarmMessage, rawMessage));
if (!StringUtil.isBlank(endpointPath)
&& splitToSet(projProperties.getNotNotifyUrl()).contains(endpointPath)) {
log.info("Skip alarm for blocked endpoint: {}", endpointPath);
return true;
}
return false;
}
......@@ -533,6 +537,18 @@ public class AlarmServiceImpl implements AlarmService {
return name.substring(slashIndex, blankIndex);
}
private String normalizeEndpointPath(String endpointPath) {
if (StringUtil.isBlank(endpointPath)) {
return "";
}
String trimmed = endpointPath.trim();
int colonIndex = trimmed.indexOf(':');
if (colonIndex > 0 && colonIndex < trimmed.length() - 1 && trimmed.charAt(colonIndex + 1) == '/') {
return trimmed.substring(colonIndex + 1);
}
return trimmed;
}
private Set<String> splitToSet(String value) {
if (StringUtil.isBlank(value)) {
return Collections.emptySet();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论