mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-29 14:43:21 -08:00
Remove fullLabels method and fix target updating
With recent changes to a Target's internal data representation updating by fullLabels() assigns the additional default instance label. This breaks target identity comparison and causes identical targets from service discovery to be constantly swapped.
This commit is contained in:
parent
209c4ad64f
commit
6df1f49c13
|
@ -405,18 +405,6 @@ func (t *Target) InstanceIdentifier() string {
|
|||
return t.host()
|
||||
}
|
||||
|
||||
func (t *Target) fullLabels() model.LabelSet {
|
||||
t.RLock()
|
||||
defer t.RUnlock()
|
||||
|
||||
lset := t.labels.Clone()
|
||||
|
||||
if _, ok := lset[model.InstanceLabel]; !ok {
|
||||
lset[model.InstanceLabel] = t.labels[model.AddressLabel]
|
||||
}
|
||||
return lset
|
||||
}
|
||||
|
||||
// RunScraper implements Target.
|
||||
func (t *Target) RunScraper(sampleAppender storage.SampleAppender) {
|
||||
defer close(t.scraperStopped)
|
||||
|
|
|
@ -278,7 +278,7 @@ func (tm *TargetManager) updateTargetGroup(tgroup *config.TargetGroup, cfg *conf
|
|||
// to build up.
|
||||
wg.Add(1)
|
||||
go func(t *Target) {
|
||||
if err := match.Update(cfg, t.fullLabels(), t.metaLabels); err != nil {
|
||||
if err := match.Update(cfg, t.labels, t.metaLabels); err != nil {
|
||||
log.Errorf("Error updating target %v: %v", t, err)
|
||||
}
|
||||
wg.Done()
|
||||
|
|
Loading…
Reference in a new issue