duplicate label key checker
This commit is contained in:
parent
eaa53f2533
commit
35ef6b9265
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue