Python Client library: Metric with same name but different label

260 views
Skip to first unread message

Vishnu B

unread,
Apr 28, 2020, 3:05:11 PM4/28/20
to Prometheus Users
I am writing a node_exporter text_file export using python client library.
I have metrics with the same metric name but different label values like below


TPL{dc="tlv1",instance="core2.tlv1",job="cisco_ipsla",link_id="PL2_31.0",region="sjc2"} 19.0
TPL{dc="ash1",instance="core1.ash1",job="cisco_ipsla",link_id="PL2_100.0",region="sjc2"} 119.0 


when I try to write this I get the below error.


```ValueError: Duplicated timeseries in CollectorRegistry: {'TPL'}```

Below is my script

registry = CollectorRegistry()
for query in queries:
for val in query:
metric_name = list(val.keys())[1]
key = list(val["metric"].keys())
g = Gauge(metric_name, 'weekly report of link status', val["metric"].keys(), registry=registry)
g.labels(**val["metric"]).set(val[metric_name][1])
write_to_textfile('/tmp/link.prom', registry)


how do I expose metric with the same name but different label value using python client_library 

Regards

Vishnu

Daniel Lacher

unread,
Feb 17, 2021, 11:13:07 PM2/17/21
to Prometheus Users
Hi Vishnu,
Did you have any luck in fixing this issue? Any solution?
I'm having a similar problem and still couldn't find an answer.
Regards,
Daniel

Reply all
Reply to author
Forward
0 new messages