Skip to content

Pushing to PushGateway is not pushing any metrics #659

@ricardoatsouza

Description

@ricardoatsouza

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)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions