pushing value to gateway and got error

63 views
Skip to first unread message

Sungmin Jeun

unread,
Apr 11, 2020, 6:05:50 AM4/11/20
to Prometheus Users
from prometheus_client import CollectorRegistry, Gauge, push_to_gateway
registry = CollectorRegistry()
g = Gauge('caliper_tps', "", ["client", "instance", "round"], registry=registry)
g.labels(client="0", instance="open2", round="0").set(0)
push_to_gateway('GATEWAY_IP_ADDRESS:9091', job='caliper', registry=registry)


i ran code above and got following error : urllib.error.HTTPError: HTTP Error 400: Bad Request

Also got error from pushgateway log :
level=error
ts=2020-04-11T09:53:48.069Z
caller=push.go:146
msg="pushed metrics are invalid or inconsistent with existing metrics"
method=PUT source=192.168.128.1:50344
err="collected metric \"caliper_tps\"
{
label:<name:\"client\" value:\"0\" >
label:<name:\"instance\" value:\"open2\" >
label:<name:\"job\" value:\"caliper\" >
label:<name:\"round\" value:\"0\" >
gauge:<value:0 > }
is not a UNTYPED"


So I build UnTyped Metric like this..
m = Metric('caliper_tps', "", "untyped")
m.add_sample('caliper_tps', {"client":"0", "instance":"open2", "round":"0"}, 0)

However I have no idea what is different between Metric name and sample name... And How Can I Push this kind of Metric to pushgateway? It doesn't have registry parameters like Gauge..

whew...
Reply all
Reply to author
Forward
0 new messages