Multiple instances send the same prometheus metric to pushgateway

1.3k views Asked by At

My task is ran on multiple machines, and for each machine, I set up the same metric as following:

myCounter = Counter
        .build()
        .name("my_counter")
        .help("Dummy counter")
        .register(registry)
pushGateway.pushAdd(registry, "myJobName")

And I don't assign label to it.

My question is, with the current way of using counter metric, will the collected value on pushgateway become incorrect, as it only retains the last pushed value ?

1

There are 1 answers

0
CloudNativeLab On

Current Logic a POST request replaces all metrics with the same name (in the group you push to) with the metrics you push. a PUT is that the latter replaces all metrics in the group by the metrics pushed.

Expect Logic a POST request replaces Only, not ALL (X) metrics with the same name (in the group you push to) with the metrics you push. (not All, But the metrics with same label values)

a PUT is that the latter replaces all metrics in the group by the metrics pushed.