docs icon indicating copy to clipboard operation
docs copied to clipboard

Add information about time functions for Unit Testing documentation (epoch)

Open MitchelNijdam-Rockstars opened this issue 5 years ago • 4 comments

As I was writing a unit test for my recording rules & alerts, based on the information on this page, I was struggling with testing alerts that use some of the time() functions, as I expected the time() functions to return the current time of my machine I was testing on.

However after a long search I stumbled upon this issue https://github.com/prometheus/prometheus/issues/4817 that explains that the time() starts from 0 and increases based on the eval_time. This also explains why day_of_week() returns 4 as it is the day on which epoch started.

I think it is good to mention this on the Unit Test page to prevent people from having to search/analyse this behavior.

What do you think about this? Doesn't have to be a whole section, maybe more like a notice.

MitchelNijdam-Rockstars avatar Oct 15 '19 14:10 MitchelNijdam-Rockstars