duplicate label key checker

This commit is contained in:
Ulric Qin 2022-07-08 12:02:57 +08:00
parent eaa53f2533
commit 35ef6b9265
1 changed files with 14 additions and 0 deletions

View File

@ -12,13 +12,27 @@ func AppendLabels(pt *prompb.TimeSeries, target *models.Target) {
return
}
labelKeys := make(map[string]struct{})
for j := 0; j < len(pt.Labels); j++ {
labelKeys[pt.Labels[j].Name] = struct{}{}
}
for key, value := range target.TagsMap {
if _, has := labelKeys[key]; has {
continue
}
pt.Labels = append(pt.Labels, &prompb.Label{
Name: key,
Value: value,
})
}
// e.g. busigroup=cloud
if _, has := labelKeys[config.C.BusiGroupLabelKey]; has {
return
}
if target.GroupId > 0 && len(config.C.BusiGroupLabelKey) > 0 {
bg := memsto.BusiGroupCache.GetByBusiGroupId(target.GroupId)
if bg == nil {