You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
The text was updated successfully, but these errors were encountered:
Push to gateway is not meant to push data back to itself, it is meant to push to a separate instance of the Pushgateway. Previously your pushes just were not doing anything, now we have slightly tighter handling of http requests so it is appropriately returning an error indicating that your program is not working as you intend.
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 inexposition.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:
The text was updated successfully, but these errors were encountered: