You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Best way to avoid ValueError: Duplicated timeseries in CollectorRegistry #745
I have dynamic metric names (new metrics will be added several times in per day). And if i try to create same double metrics i get an Exception: ValueError: Duplicated timeseries in CollectorRegistry:
But i do not understand, how can i check if metric already exists. Could you please help me?
For example, code:
promet_metricks = {}
def get_beer_can_name_from_onlime_shop_function():
''''In real program this huge function to get beers from online shop and parse available beers'''
return ("Baltika", "Heinz", "Giguli", "Vodka_lite")
def prom():
beer_cans = get_beer_can_name_from_onlime_shop_function()
for current_beer_can in beer_cans:
promet_metricks[current_beer_can] = prometheus_client.Counter(current_beer_can, "Counter can of beer which drink my dad")
promet_metricks[current_beer_can].inc()
time.sleep(3)
while True:
prom()
How can i check that metric already exists and i should not create them.
Currently i am using
try:
promet_metricks[current_beer_can] = prometheus_client.Counter(current_beer_can, "Counter can of beer which drink my dad")
except ValueError:
pass
Activity
[-]Best way to avoid [/-][+]Best way to avoid ValueError: Duplicated timeseries in CollectorRegistry[/+]