-
Notifications
You must be signed in to change notification settings - Fork 840
Closed
Description
Hello,
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
But i do not think that it is best solution.
Metadata
Metadata
Assignees
Labels
No labels