Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

register collector with error duplicate metrics collector registration attempted #5477

Closed
qianfangyuan opened this Issue Apr 18, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@qianfangyuan
Copy link

qianfangyuan commented Apr 18, 2019

register with collector with error duplicate metrics collector registration attempted

prometheus save collector with a uint64 number with key, and collector as value
collectorsByID map[uint64]Collector // ID is a hash of the descIDs.
the number is calculate with each ConstLabels and fqName and add that all:

func fq(labelValues[]string)uint64{
vh := hashNew()
for _, val := range labelValues {
vh = hashAdd(vh, val)
vh = hashAddByte(vh, separatorByte)
}
return vh

}

const (
offset64 = 14695981039346656037
prime64 = 1099511628211
)
const separatorByte byte = 255

// hashNew initializies a new fnv64a hash value.
func hashNew() uint64 {
return offset64
}

// hashAdd adds a string to a fnv64a hash value, returning the updated hash.
func hashAdd(h uint64, s string) uint64 {
for i := 0; i < len(s); i++ {
h ^= uint64(s[i])
h *= prime64
}
return h
}

// hashAddByte adds a byte to a fnv64a hash value, returning the updated hash.
func hashAddByte(h uint64, b byte) uint64 {
h ^= uint64(b)
h *= prime64
return h
}

when two collectors have the same fqName and different ConstLabels
collectorA:
labelValues1=[]string{"mysql_exporter_scrapes_total","3411"}
labelValues2=[]string{"mysql_exporter_scrape_errors_total","3411"}
labelValues3=[]string{"mysql_exporter_last_scrape_error","3411"}
labelValues4=[]string{"mysql_up","3411"}
cal:
9288655250343904629+16028598718722608554+9509180690289043793+5153831169212418182-18446744073709551615*2=3086777681148871926

collectorB:
labelValues1=[]string{"mysql_exporter_scrapes_total","3413"}
labelValues2=[]string{"mysql_exporter_scrape_errors_total","3413"}
labelValues3=[]string{"mysql_exporter_last_scrape_error","3413"}
labelValues4=[]string{"mysql_up","3413"}
cal:
9290907050158102307+16026346918908410876+9510869540149597439+5152142319351864536-18446744073709551615*2=3086777681148871926
but have the same cal id:3086777681148871926

with different constLabels but cal the same collectorID,so register failed

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Apr 18, 2019

It makes more sense to ask questions like this on the prometheus-users mailing list rather than in a GitHub issue. On the mailing list, more people are available to potentially respond to your question, and the whole community can benefit from the answers provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.