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