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...

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/ad6d721a-e409-465d-b469-ed584f44db20%40googlegroups.com.

Reply via email to