Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upregister collector with error duplicate metrics collector registration attempted #5477
Comments
This comment has been minimized.
This comment has been minimized.
|
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. |
brian-brazil
closed this
Apr 18, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
qianfangyuan commentedApr 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