Sum per time interval?

5,711 views
Skip to first unread message

Harmen B

unread,
Nov 12, 2015, 9:34:57 AM11/12/15
to Prometheus Developers
Hi!

is there a way to sum() a counter per time period?
I have a counter of which I would like to graph the sum per (UTC) day, with a reset at midnight, counting upwards during the day. A single number per day would be fine.

I can see this work with a Gauge, to which I .Add() all day, with somehow a Set(0) at midnight, but that sounds ugly. Any other ideas?

Thanks!
Harmen

Fabian Reinartz

unread,
Nov 12, 2015, 9:45:29 AM11/12/15
to Harmen B, Prometheus Developers
Hi,

you can use the increase() function in an instant query evaluated at 00:00h with a 24h window (`increase(my_counter[24h])`).
This will return you the number by which the counter increased the past day. No need to modify the metrics themselves.

Cheers,
Fabian

--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-devel...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Harmen B

unread,
Nov 12, 2015, 10:36:06 AM11/12/15
to Fabian Reinartz, Prometheus Developers
Hi,

thanks for your reply. That means I still have to call the query at 00:00h sharp every day and store the result somehow. Right?

Brian Brazil

unread,
Nov 12, 2015, 10:42:36 AM11/12/15
to Harmen B, Fabian Reinartz, Prometheus Developers
On Thu, Nov 12, 2015 at 3:36 PM, Harmen B <har...@typetypetype.net> wrote:
Hi,

thanks for your reply. That means I still have to call the query at 00:00h sharp every day and store the result somehow. Right?


Brian



--

Harmen B

unread,
Nov 12, 2015, 11:08:25 AM11/12/15
to Brian Brazil, Fabian Reinartz, Prometheus Developers
So then it's a cron which runs daily, a little after midnight, calculating the total from yesterday with `increase(mycounter[1d])`, and put that in a new gauge. Right?

Thanks!
Harmen
Message has been deleted

mounia zadel

unread,
Jul 18, 2018, 4:59:36 PM7/18/18
to Prometheus Developers


Le mardi 17 juillet 2018 20:02:05 UTC+1, mounia zadel a écrit :
I have a table which will log all the data based on one minute interval. Now I want to retrieve the records such that, if the time interval is given 2 minutes it should add the complete records with 2 minutes interval and show on screen .I watch this vedeo to an article  https://bluestacks.vip/, https://textnow.vip/, https://photomath.vip/

Reply all
Reply to author
Forward
0 new messages