Hi Brian, thank you for you replay. The first thing with "*GaugeMetricFamily" * I figured out just a few minutes after my first reply.
To the second thing you pointed out: Can you give me an example for how to create a registry per request? If i try to use "*req = REGISTRY()*" i get the error "'*CollectorRegistry' object is not callable*". Brian Brazil schrieb am Dienstag, 22. September 2020 um 13:19:32 UTC+2: > On Tue, 22 Sep 2020 at 11:06, Sebastian Halter <[email protected]> > wrote: > >> Thats what i tried: >> >> *g = GaugeMetricFamily("cardTemperature", "Temperature of the installed >> card", labels=["card"])* >> > > This should be inside the collector. > > >> >> *class TL1Collector(object):* >> * def __init__(self, endpoint):* >> * self._endpoint = endpoint* >> >> * def collect(self):* >> * g.add_metric(self._endpoint, 2)* >> * yield g* >> >> *@app.route("/temperature")* >> *def handle_get():* >> * if "target" in request.args:* >> * target = request.args.get('target')* >> * REGISTRY.register(TL1Collector(target))* >> > > Create a registry per request, and register with that. > > Brian > > >> * return generate_latest(REGISTRY)* >> * else:* >> * return "Error: No target field provided. Please specify target.* >> " >> >> I'm probably wrong the line "*REGISTRY.register(TL1Collector(target))" >> *because >> i register the collector every time i call the endpoint and it is already >> registered from the http call before that one. >> But i don't know where to register the custom collector to prevent that, >> because i need the target variable to be passed through. >> If i only trigger it once at the start with a boolean it works serveral >> times and i dont get that error anymore but in only adds another metric to >> the output an keeps the old data from a different target parameter aswell. >> [email protected] schrieb am Dienstag, 22. September 2020 um 11:31:43 >> UTC+2: >> >>> You probably need to use the Custom Collector. This is similar to the >>> "Const" metrics in the Go code. >>> >>> https://github.com/prometheus/client_python#custom-collectors >>> >>> On Tue, Sep 22, 2020 at 11:03 AM Sebastian Halter < >>> [email protected]> wrote: >>> >>>> Hello everyone, >>>> >>>> i am trying to collect some data via TL1 (basically telnet) because the >>>> manufacturer doesn't provide the temperature of the installed cards via >>>> SNMP. >>>> >>>> I would like to recreate something like the SNMP-Exporter where i can >>>> specify my target in the URL it scrapes. Currently i am facing the issue, >>>> that my exporter runs once and then it runs into an error on every other >>>> request ("ValueError: Duplicated timeseriers in CollectorRegistry"). >>>> >>>> Does anyone have a basic example of a multi-target python exporter? >>>> I found in the documentation that python, go und java are the only >>>> client libraries that supports this approch but couldn't find any example >>>> of this on the python-client github site. >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Prometheus Users" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/prometheus-users/2f7dd7e7-ac2e-4cee-8f55-68390051efd9n%40googlegroups.com >>>> >>>> <https://groups.google.com/d/msgid/prometheus-users/2f7dd7e7-ac2e-4cee-8f55-68390051efd9n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "Prometheus Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> > To view this discussion on the web visit >> https://groups.google.com/d/msgid/prometheus-users/f2fa5473-3fdd-408f-9089-0e75d927207an%40googlegroups.com >> >> <https://groups.google.com/d/msgid/prometheus-users/f2fa5473-3fdd-408f-9089-0e75d927207an%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > > > -- > Brian Brazil > www.robustperception.io > -- You received this message because you are subscribed to the Google Groups "Prometheus Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/e0884d8d-460e-4733-9186-ccf7b607685bn%40googlegroups.com.

