Hi Achintya,

On Tue, Jan 10, 2023 at 9:29 AM 'Achintya Kumar' via Prometheus Users <
[email protected]> wrote:

> Hey Guys,
> I am using github.com/prometheus/client_golang/prometheus/push in my
> Golang code to push metrics to a push gateway.
> But I wanted to understand the core difference between Add and Push. I am
> currently using Add to push the metrics but still have some confusions
> regarding which previous metrics will it


Add() will replace only any metrics with the same metric name and labels
(so the same time series identity) within a pushed group, if metrics with
the same name and labels have been pushed before. In contrast, Push()
completely removes all previous metrics in a pushed group and then only
adds the newly pushed ones. So you can use Add() instead if you are not
sending *all* possible metrics to a group every time, and you don't
want the old ones to disappear.


> replace? Also, I want to use the pusher.Add function to be run after every
> 10 seconds rather than pushing metrics right away. How can I achieve that?
> The prometheus/push package doesn't have this kind of functionality.
>

If you really want that you'll have to implement that yourself by just
having a goroutine running in the background that pushes your metrics every
10 seconds. Just be aware of the general limitations of what the
Pushgateway should be used for at
https://prometheus.io/docs/practices/pushing/. Most of the time it's just
used to push metrics once, at the end of a batch job run, but in some cases
it can also make sense to push metrics on a more ongoing basis, like if you
want to report on the progress of an ongoing batch job while it's running.

Julius


> Thank you.
> This message and its attachments are confidential (or legally privileged)
> information and are meant solely for the addressee of such message. Any
> unauthorized use of the message / its attachments is strictly prohibited.
>
> --
> 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/a1df943c-1146-4c39-9983-f077952d1f28n%40googlegroups.com
> <https://groups.google.com/d/msgid/prometheus-users/a1df943c-1146-4c39-9983-f077952d1f28n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Julius Volz
PromLabs - promlabs.com

-- 
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/CAObpH5zPuqJPz3owVnhSujtK_UAWu4d92pz7dPSc8E9VwoTYTA%40mail.gmail.com.

Reply via email to