fix(monitor): resource id deduplication of alert record (#24032)

This commit is contained in:
Zexi Li
2026-01-07 11:15:51 +08:00
committed by GitHub
parent e7dee4e9a0
commit 317497d6c2
+6 -6
View File
@@ -362,28 +362,28 @@ func (record *SAlertRecord) CustomizeCreate(
if err != nil {
return errors.Wrap(err, "GetEvalData error")
}
resIds := []string{}
resIds := sets.NewString()
for _, match := range matches {
for k, v := range match.Tags {
switch k {
case "vm_id":
if record.ResType == monitor.METRIC_RES_TYPE_AGENT || record.ResType == monitor.METRIC_RES_TYPE_GUEST {
resIds = append(resIds, v)
resIds.Insert(v)
}
case "host_id":
if record.ResType == monitor.METRIC_RES_TYPE_HOST {
resIds = append(resIds, v)
resIds.Insert(v)
}
case "cloudaccount_id":
if record.ResType == monitor.METRIC_RES_TYPE_CLOUDACCOUNT {
resIds = append(resIds, v)
resIds.Insert(v)
}
case "id":
resIds = append(resIds, v)
resIds.Insert(v)
}
}
}
record.ResIds = strings.Join(resIds, ",")
record.ResIds = strings.Join(resIds.List(), ",")
return nil
}