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

LogQL: Add unwrap bytes() conversion function #2876

Merged
merged 2 commits into from
Nov 4, 2020

Conversation

jkellerer
Copy link
Contributor

@jkellerer jkellerer commented Nov 4, 2020

What this PR does / why we need it:

This PR adds the bytes() conversion function to unwrap. While LogQL allows parsing bytes and duration values, the unwrap conversion provides only a method to handle duration, however many log files contain human readable byte values which should be convertible to raw bytes.

With this PR queries like the following are supported:

sum_over_time(
    {app="restic"}
        |~ `Added to the repo:.+`
        | regexp `.+repo: (?P<size>[\d\.]+ \w+)`
        | unwrap bytes(size)[10m]
)

For a log line like this:

Added to the repo: 8.369 MiB

Which issue(s) this PR fixes:
None

Special notes for your reviewer:
Parser was modified (including generated code).

Checklist

  • Documentation added
  • Tests updated

@CLAassistant
Copy link

CLAassistant commented Nov 4, 2020

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

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

LGTM

Really big thanks for this, we were supposed to add it soon, but guess you beat us at it.

@cyriltovena cyriltovena merged commit c394ce9 into grafana:master Nov 4, 2020
@jkellerer
Copy link
Contributor Author

Thanks a lot for the fast response!
Appreciate that it was added as my workaround is not pretty...

@jkellerer jkellerer deleted the ft-unwrap-bytes-conversion branch November 4, 2020 13:21
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.

3 participants