-
Notifications
You must be signed in to change notification settings - Fork 8.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
template: adding toTime function to TemplateExpander #10993
Conversation
cd2dc99
to
1397984
Compare
Thanks, I think it would be better to instead add a "toTime" function that takes a unix epoch time and can convert it to a (This is similar to what is possible in alertmanager, e.g. prometheus/alertmanager#1188 (comment)) |
I can do that. |
@dgl done. |
Thanks!
|
2140509
to
7f3b18f
Compare
@roidelapluie I have separated out the pieces of the functions that I could. I had to leave |
c20c19c
to
331d24e
Compare
@roidelapluie is there anything I missed here? |
@roidelapluie requests resolved. |
567f922
to
613de5d
Compare
Signed-off-by: Jonathan Stevens <jonathanstevens89@gmail.com> Signed-off-by: Jonathan Stevens <jon.stevens@getweave.com>
Thanks! |
…ay as Prometheus 2.38 does See prometheus/prometheus#10993
…ay as Prometheus 2.38 does See prometheus/prometheus#10993
This PR adds a
formatTime
function in the TemplateExpander. As it stands now, the way to get the current time of a PromQL execution is to do something like this:{{ query "time()" | first | value || humanizeTime }}
. This works great but only allows one format of time to be expressed. I'm proposing a simple function that does virtually the exact same thing ashumanizeTime
except that it allows you to pass in the format you expect to get back like this:{{ query "time()" | first | value || formatTime "2006-01-02 15:04:05" }}