prometheuspromqlprometheus-pushgateway

Prometheus count and sum metric over restart of pushgateway


I want to count how often a user opens a dialog in a frontend and send the results to the prometheus pushgateway.

The problem is that once the gateway restarts the metrics are gone and I can not sum the values properly.

enter image description here

The rate function seems not to fit for this purpose.

Is there the possibility to sum over time, no matter there where restarts or not?

Here is the sum query but shows not what I expect. enter image description here

maybe sum_over_time could do it if I group them, but if I add the by clause it throws an error.

enter image description here


Solution

  • You're probably looking for increase, rather than rate. Which is the same as rate * <interval_length_in_seconds>.

    As a side note, in theory Pushgateway persists its state across restarts, but if you're running it within Docker or Kubernetes you would need to set up a persistent volume to be used by your successive Pushgateway instances.