diff --git a/internal/component/discovery/discovery.go b/internal/component/discovery/discovery.go index 03670814e1..4ab9f7342b 100644 --- a/internal/component/discovery/discovery.go +++ b/internal/component/discovery/discovery.go @@ -9,6 +9,7 @@ import ( "sync" "time" + "github.com/josharian/intern" "github.com/prometheus/common/model" "github.com/prometheus/prometheus/discovery" "github.com/prometheus/prometheus/discovery/targetgroup" @@ -261,6 +262,7 @@ func (c *Component) runDiscovery(ctx context.Context, d DiscovererWithMetrics) { } func toAlloyTargets(cache map[string]*targetgroup.Group) []Target { + // TODO(thampiotr): HOT SPOT #1 targetsCount := 0 for _, group := range cache { targetsCount += len(group.Targets) @@ -274,10 +276,10 @@ func toAlloyTargets(cache map[string]*targetgroup.Group) []Target { // first add the group labels, and then the // target labels, so that target labels take precedence. for k, v := range group.Labels { - tLabels[string(k)] = string(v) + tLabels[intern.String(string(k))] = intern.String(string(v)) } for k, v := range target { - tLabels[string(k)] = string(v) + tLabels[intern.String(string(k))] = intern.String(string(v)) } allTargets = append(allTargets, tLabels) } diff --git a/internal/component/discovery/relabel/relabel.go b/internal/component/discovery/relabel/relabel.go index 6613c6c801..a7d4e63874 100644 --- a/internal/component/discovery/relabel/relabel.go +++ b/internal/component/discovery/relabel/relabel.go @@ -5,13 +5,14 @@ import ( "fmt" "sync" + "github.com/prometheus/prometheus/model/labels" + "github.com/prometheus/prometheus/model/relabel" + "github.com/grafana/alloy/internal/component" alloy_relabel "github.com/grafana/alloy/internal/component/common/relabel" "github.com/grafana/alloy/internal/component/discovery" "github.com/grafana/alloy/internal/featuregate" "github.com/grafana/alloy/internal/service/livedebugging" - "github.com/prometheus/prometheus/model/labels" - "github.com/prometheus/prometheus/model/relabel" ) func init() { @@ -92,9 +93,11 @@ func (c *Component) Update(args component.Arguments) error { c.rcs = relabelConfigs for _, t := range newArgs.Targets { + // TODO(thampiotr): HOT SPOT #2 lset := componentMapToPromLabels(t) relabelled, keep := relabel.Process(lset, relabelConfigs...) if keep { + // TODO(thampiotr): HOT SPOT #3 targets = append(targets, promLabelsToComponent(relabelled)) } componentID := livedebugging.ComponentID(c.opts.ID)