-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
add date time sprig template functions in logql label/line formatter #4603
Conversation
8231545
to
f50edb2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @garrettlish! LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks nice 👍 Thanks @garrettlish. Left one minor suggestions.
And can you also please update the ``CHANGELOG.md`?
|
||
## date | ||
|
||
`date` returns a textual representation of the time value formatted according to layout. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: about the layout
. Can we explain bit about it? What are the other options? (is it same as golang's datetime layout?, if yes, we can mention that and refer the doc to the layout?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good question. I'm not actually sure, although I expected it was the same as golang's.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are correct, it is golang datetime layout, added doc references to the layout - a4aa5e7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. thanks for adding the the clarification! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
With date time sprig template functions, we will be able to filter test jobs which create time is 1 day before as the following: ``` {job="test"} | label_format nowEpoch=`{{(unixEpoch now)}}`,createDateEpoch=`{{unixEpoch (toDate "2006-01-02" .createDate)}}` | label_format dateTimeDiff="{{sub .nowEpoch .createDateEpoch}}" | dateTimeDiff > 86400 ```
* add golang datetime layout doc reference * update CHANGELOG.md accordingly to include this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Nice examples
What this PR does / why we need it:
Introduce date time sprig template functions in logql label/line formatter, it allows us to get current time, format date time and parse date time with specified layout.
Which issue(s) this PR fixes:
Fixes #4511, we will be able to filter test jobs which create time is 1 day before as the following:
Special notes for your reviewer:
N/A
Checklist