Hello,
could you solve the probelm?
I have a similar error.
Thanks.

El sábado, 8 de septiembre de 2018, 22:12:29 (UTC-3), [email protected] 
escribió:
>
> I call the exporter on every 15s and send an array of target urls. Can you 
> expand your answer?   
>
> On Saturday, September 8, 2018 at 9:36:13 PM UTC+5:30, Brian Brazil wrote: 
> > On 8 September 2018 at 13:01,  <[email protected]> wrote: 
> > I have written a custom exporter to parse json output of target urls. 
> > 
> > 
> > 
> > from prometheus_client import start_http_server, Metric, 
> generate_latest, Summary 
> > 
> > from prometheus_client.core import SummaryMetricFamily, 
> GaugeMetricFamily, CounterMetricFamily, REGISTRY 
> > 
> > import json 
> > 
> > import requests 
> > 
> > import sys 
> > 
> > import time 
> > 
> > import flask 
> > 
> > from flask import request, jsonify 
> > 
> > 
> > 
> > app = flask.Flask(__name__) 
> > 
> > app.config["DEBUG"] = True 
> > 
> > 
> > 
> > class JsonCollector(object): 
> > 
> >   def __init__(self, endpoint): 
> > 
> >     self._endpoint = endpoint 
> > 
> >   def collect(self): 
> > 
> >     # Fetch the JSON 
> > 
> >     flag=0 
> > 
> >     print self._endpoint 
> > 
> >     response = 
> json.loads(requests.get(self._endpoint).content.decode('UTF-8')) 
> > 
> >     print response 
> > 
> >     if(response['status']=='Running'): 
> > 
> >         flag=1 
> > 
> >     metric = Metric('status','Flag value is 1 if status is 
> success','summary') 
> > 
> >     metric.add_sample('status',value=flag, labels={}) 
> > 
> >     yield metric 
> > 
> > 
> > 
> > @app.route('/probe', methods=['GET']) 
> > 
> > def api_url(): 
> > 
> >     if 'target' in request.args: 
> > 
> >         url = request.args['target'] 
> > 
> > 
> > 
> > 
> > 
> >   
> >         REGISTRY.register(JsonCollector(url)) 
> > 
> > 
> > 
> > You only need to call this once, not on every request. 
> > 
> > 
> > Brian 
> >   
> >         data=generate_latest(REGISTRY) 
> > 
> >         return data 
> > 
> >     else: 
> > 
> >         return "Error: No target field provided. Please specify target." 
> > 
> > 
> > 
> > app.run(host='0.0.0.0') 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > Issue: 
> > 
> > ValueError: Duplicated timeseries in CollectorRegistry: set([u'status', 
> u'status_sum', u'status_count']) 
> > 
> > 
> > 
> > -- 
> > 
> > You received this message because you are subscribed to the Google 
> Groups "Prometheus Developers" group. 
> > 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to [email protected] 
> <javascript:>. 
> > 
> > To post to this group, send email to [email protected]. 
> > 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/prometheus-developers/7519f9d4-82ff-44a6-acab-06de2ce564e7%40googlegroups.com.
>  
>
> > 
> > For more options, visit https://groups.google.com/d/optout. 
> > 
> > 
> > 
> > 
> > 
> > -- 
> > 
> > 
> > Brian Brazil 
> > www.robustperception.io 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Developers" 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-developers/04324f4c-031f-465b-9648-8b4cd2212809%40googlegroups.com.

Reply via email to