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))
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'])
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 prometheus-developers+unsub...@googlegroups.com.
To post to this group, send email to prometheus-developers@googlegroups.com.
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.
> To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-developers+unsub...@googlegroups.com.