Skip to content
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

Merged
merged 2 commits into from
Feb 3, 2022

Conversation

ssncferreira
Copy link
Contributor

@ssncferreira ssncferreira commented Feb 1, 2022

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

  • Documentation added
  • Tests updated
  • Add an entry in the CHANGELOG.md about the changes.

@ssncferreira ssncferreira force-pushed the issue/5288-promtail_metrics_duration_string branch 3 times, most recently from 1a1c3d3 to 0715029 Compare February 1, 2022 15:51
@ssncferreira ssncferreira marked this pull request as ready for review February 1, 2022 16:09
func getFloatFromString(str string) (float64, error) {
dur, err := strconv.ParseFloat(str, 64)
if err != nil {
dur, err := time.ParseDuration(str)
Copy link
Contributor Author

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:

I would say that the one from time package has the most suitable set for this use case. Wdyt?

Copy link
Contributor

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

Copy link
Contributor

@dannykopping dannykopping left a 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)
Copy link
Contributor

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

clients/pkg/logentry/stages/metrics_test.go Outdated Show resolved Hide resolved
@ssncferreira ssncferreira force-pushed the issue/5288-promtail_metrics_duration_string branch from 2d025f3 to d422760 Compare February 2, 2022 16:35
Copy link
Contributor

@dannykopping dannykopping left a 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

@ssncferreira ssncferreira force-pushed the issue/5288-promtail_metrics_duration_string branch from d422760 to 626650d Compare February 3, 2022 10:05
Copy link
Contributor

@kavirajk kavirajk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@dannykopping dannykopping merged commit 82fac99 into main Feb 3, 2022
@dannykopping dannykopping deleted the issue/5288-promtail_metrics_duration_string branch February 3, 2022 10:42
KMiller-Grafana pushed a commit to KMiller-Grafana/loki that referenced this pull request Feb 4, 2022
* Update promtail to support duration string formats

* Address comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Promtail metrics support duration string formats
3 participants