Skip to content

Commit b5ce5c9

Browse files
authored
[fix] refactor system built-in labels validation logic (#3946)
1 parent a19a399 commit b5ce5c9

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

hertzbeat-alerter/src/main/java/org/apache/hertzbeat/alert/service/impl/AlertDefineServiceImpl.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ public class AlertDefineServiceImpl implements AlertDefineService {
9090

9191
private static final String CONTENT_TYPE = MediaType.APPLICATION_OCTET_STREAM_VALUE + SignConstants.SINGLE_MARK + "charset=" + StandardCharsets.UTF_8;
9292

93+
private static final Set<String> SYSTEM_BUILT_IN_LABELS = Set.of(
94+
CommonConstants.LABEL_INSTANCE,
95+
CommonConstants.LABEL_DEFINE_ID,
96+
CommonConstants.LABEL_ALERT_NAME,
97+
CommonConstants.LABEL_INSTANCE_NAME,
98+
CommonConstants.LABEL_ALERT_SEVERITY,
99+
CommonConstants.ALERT_MODE_LABEL
100+
);
101+
93102
public AlertDefineServiceImpl(List<AlertDefineImExportService> alertDefineImExportServiceList, DataSourceService dataSourceService) {
94103
alertDefineImExportServiceList.forEach(it -> alertDefineImExportServiceMap.put(it.type(), it));
95104
this.dataSourceService = dataSourceService;
@@ -148,7 +157,7 @@ private void saveNewCustomLabel(AlertDefine alertDefine) {
148157
}
149158

150159
private boolean isSystemBuiltInLabel(String labelKey) {
151-
return CommonConstants.ALERT_MODE_LABEL.equals(labelKey) || CommonConstants.LABEL_ALERT_SEVERITY.contains(labelKey);
160+
return SYSTEM_BUILT_IN_LABELS.contains(labelKey);
152161
}
153162

154163
@Override

0 commit comments

Comments
 (0)