-
Notifications
You must be signed in to change notification settings - Fork 845
Pushing to PushGateway is not pushing any metrics #659
Description
Hello,
I have a set of metrics in my batch job, all of them being created in the following way:
r = CollectorRegistry()
...
c = Counter(<name>, <description>, registry=r, labelnames=<global_label_names>, labelvalues=<global_label_values>)In my use case, I have a small set of global labels that I define to every metric when they are created. Then, at the end of the batch job, the metrics are pushed to PushGateway through the push_to_gateway function. The command runs successfully. However, in PushGateway, none of the metrics is actually there.
push_to_gateway(<url>, job=<job_name>, registry=r)While trying to understand why, I crossed with this line in the code. Basically, the created metrics are only added to the given registry r when there are no labels given to it. Consequently, the registry r is empty when push_to_gateway runs.
I wonder if this is the intended behaviour. In case positive, is there a way to use the global prometheus registry in push_to_gateway (registry is a required parameter in the function call)?