Skip to content

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

@MitchelNijdam-Rockstars

Description

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 prometheus/prometheus#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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions