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
|
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 {
|
for key, value := range target.TagsMap {
|
||||||
|
if _, has := labelKeys[key]; has {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
pt.Labels = append(pt.Labels, &prompb.Label{
|
pt.Labels = append(pt.Labels, &prompb.Label{
|
||||||
Name: key,
|
Name: key,
|
||||||
Value: value,
|
Value: value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// e.g. busigroup=cloud
|
||||||
|
if _, has := labelKeys[config.C.BusiGroupLabelKey]; has {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if target.GroupId > 0 && len(config.C.BusiGroupLabelKey) > 0 {
|
if target.GroupId > 0 && len(config.C.BusiGroupLabelKey) > 0 {
|
||||||
bg := memsto.BusiGroupCache.GetByBusiGroupId(target.GroupId)
|
bg := memsto.BusiGroupCache.GetByBusiGroupId(target.GroupId)
|
||||||
if bg == nil {
|
if bg == nil {
|
||||||
|
|
Loading…
Reference in New Issue