Closed
Description
Hello, I'm still a newbie, so maybe I am misinterpreting something, but it appears as if there's an issue with the push_to_gateway()
function defined in exposition.py
.
Since v0.21 has been released, I cannot get my custom collector to expose its metrics over HTTP. It appears that even though the WSGI server when start_http_server()
only supports OPTION and GET as methods, push_to_gateway()
uses PUT, which gives me a "405 Method Not Allowed" error. Since my little program runs flawlessly with v0.20, I'm inclined to believe this may be a bug.
Here's what works in v0.20:
import prometheus_client
from prometheus_client.core import GaugeMetricFamily
import requests
import time
class MyCollector(object):
def __init__(self):
pass
def collect(self):
datajson = requests.get('https://api.example.com/foo)
rawdata = datajson.json()
registry = prometheus_client.CollectorRegistry()
g = GaugeMetricFamily('mymetric', 'My Gauge Metric', value=rawdata['meta']['total'])
yield g
if __name__ == '__main__':
prometheus_client.start_http_server(8000)
R = prometheus_client.REGISTRY.register(MyCollector())
while True:
prometheus_client.push_to_gateway('localhost:8000', job='gaugemetricvalues', registry=R)
time.sleep(3600)
Metadata
Metadata
Assignees
Labels
No labels