How to push metrics use python2 requests? #500
m986883511
started this conversation in
General
Replies: 1 comment
-
I solve it, but too simple. import requests
url = "http://192.223.44.211:9091/metrics/job/test_job/instance/host001"
headers = {'X-Requested-With': 'Python requests','Content-type': 'text/plain'}
metric_name, value = 'db_error', 1 # value must be float
payload = "{} {}\n".format(metric_name, value)
res=requests.post(url, headers=headers, data=payload)
print(res.status_code, res.text) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
My product env only have python2, so I can not use prometheus-client, I search for a long time, I dont know how to push use python2 requests.
this is my demo code:
output
Any one can help me
Beta Was this translation helpful? Give feedback.
All reactions