Periodic Time Signal in PromQL

49 views
Skip to first unread message

Daniel Curilla

unread,
Jun 2, 2022, 1:53:23 PM6/2/22
to Prometheus Users
Hi everyone! 

I am looking for some help on a PromQL problem. Right now, I am trying to create a periodic time signal that has a 24h hour period on a specific time for each day. For example, I would like to create a graph that shows the timestamp value at 8:30 UTC every 24h. So, over a 7 week interval, there would be 1 data point a day with a value equal to the timestamp occurring at 8:30 UTC for that day. 

Any help is greatly appreciated!

Julien Pivotto

unread,
Jun 2, 2022, 3:25:05 PM6/2/22
to Prometheus Users
Hello,

You can use:

time() - hour(vector(time())-8.5*3600)*3600 - minute(vector(time())-8.5*3600)*60 - time()%60


If you want only at that time, you could try, so it will be firing for 5 minutes every day at 8.30:

time() - hour(vector(time())-8.5*3600)*3600 - minute(vector(time())-8.5*3600)*60 - time()%60 and time() - hour(vector(time())-8.5*3600)*3600 - minute(vector(time())-8.5*3600)*60 - time()%60 - time() > -300

Regards,

Julien Pivotto

unread,
Jun 2, 2022, 4:26:44 PM6/2/22
to Prometheus Users
if it is for alertingm you can also do

hour() == 8 and minute() == 30.
> --
> 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 prometheus-use...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/c1b1001c-7d80-4bbb-98c0-062d13d0d7c7n%40googlegroups.com.


--
Julien Pivotto
@roidelapluie
Reply all
Reply to author
Forward
0 new messages