With the help of Python request.get and json.loads functions, I was able to source the data from an URL. The data contain a list of instances where each one of them have metrics such as instance_id, status, etc.
My question is that is there any way I could upload those metrics to Prometheus? I looked into the pushgateway function but was not sure if that is the correct way of doing data pushing and storage.
My current effort to push data to Prometheus is the following:
from prometheus_client import CollectorRegistry, Gauge, push_to_gateway
from prometheus_client import Summary
registry1 = CollectorRegistry()
registry2 = CollectorRegistry()
s = Summary('request_latency_seconds', 'Description of summary', registry=registry1)
s.observe(4.7)
g = Gauge('job_last_success_unixtime', 'Last time a batch job successfully finished', registry=registry2)
g.set_to_current_time()
push_to_gateway('localhost:9091', job='batch_summary', registry=registry1)
push_to_gateway('localhost:9091', job='batch_gauge', registry=registry2)
However, I am not sure what metric type I should be pushing (Gauge, Summary or something else?)
Here is an example of the instance data I wish to push:
{'url': 'https://example.com',
'created': '2017-09-17-time',
'status_code': 200,
'instance_start': '2018-09-17-time', }
The reason why I am pushing that data to Prometheus is that I wanted to use Grafana to get those data and visualize them.
An example Grafana graph would be: time as x-axis, number of instances with status-code: 200 as y-axis.
Any thoughts or help will be appreciated. Thank you!