diff --git a/src/server/common/label_append.go b/src/server/common/label_append.go index d1574315..bdce9fd7 100644 --- a/src/server/common/label_append.go +++ b/src/server/common/label_append.go @@ -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 {