-
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
Update promtail to support duration string formats #5290
Update promtail to support duration string formats #5290
Conversation
1a1c3d3
to
0715029
Compare
func getFloatFromString(str string) (float64, error) { | ||
dur, err := strconv.ParseFloat(str, 64) | ||
if err != nil { | ||
dur, err := time.ParseDuration(str) |
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.
@dannykopping you suggested using ParseDuration
from github.com/prometheus/common/model instead of the one from time package. They support different time units:
- prometheus: supports bigger time units "y", "w", "d", "h", "m", "s", "ms"
https://github.com/grafana/loki/blob/main/vendor/github.com/prometheus/common/model/time.go#L186 - time: supports smaller time units "ns", "us", "ms", "s", "m", "h"
I would say that the one from time package has the most suitable set for this use case. Wdyt?
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.
I tend to agree; I think the smaller units are probably more valuable here. Good call
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 a minor nit 👍
func getFloatFromString(str string) (float64, error) { | ||
dur, err := strconv.ParseFloat(str, 64) | ||
if err != nil { | ||
dur, err := time.ParseDuration(str) |
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.
I tend to agree; I think the smaller units are probably more valuable here. Good call
2d025f3
to
d422760
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.
LGTM
Please remember to not force-push after a review has started in future
d422760
to
626650d
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.
LGTM 👍
* Update promtail to support duration string formats * Address comments
What this PR does / why we need it:
Promtail metrics support duration string formats
Which issue(s) this PR fixes:
Fixes #5288
Special notes for your reviewer:
Checklist
CHANGELOG.md
about the changes.