Skip to content

Commit

Permalink
fix: skip duplicate data source names in ValueList
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Hösler <[email protected]>
  • Loading branch information
hoesler committed Jun 28, 2019
1 parent 4b78624 commit 35c2db7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ endif
.PHONY: common-build
common-build: promu
@echo ">> building binaries"
GO111MODULE=$(GO111MODULE) $(PROMU) build --prefix $(PREFIX)
GO111MODULE=$(GO111MODULE) GOOS=$(GOHOSTOS) GOARCH=$(GOHOSTARCH) $(PROMU) build --prefix $(PREFIX)

.PHONY: common-tarball
common-tarball: promu
Expand Down
20 changes: 14 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,22 @@ func (c collectdCollector) Collect(ch chan<- prometheus.Metric) {
continue
}

// prevent duplicate metrics
dsNameSeen := make(map[string]bool)

for i := range vl.Values {
m, err := newMetric(vl, i)
if err != nil {
log.Errorf("newMetric: %v", err)
continue
}
dsName := vl.DSName(i)
if _, ok := dsNameSeen[dsName]; !ok {
dsNameSeen[dsName] = true

m, err := newMetric(vl, i)
if err != nil {
log.Errorf("newMetric: %v", err)
continue
}

ch <- m
ch <- m
}
}
}
}
Expand Down

0 comments on commit 35c2db7

Please sign in to comment.