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

Use un-escaped regexp literal for string matching. #9252

Merged
merged 1 commit into from
Apr 24, 2023

Conversation

jeschkies
Copy link
Contributor

@jeschkies jeschkies commented Apr 24, 2023

What this PR does / why we need it:
The Regexp simplification would use the original string value instead of the escaped literal. E.g. | logfmt | level =~ `foo\.bar` would match the label level against foo\.bar and not foo.bar.

That is why the un-escaped literalt should be used in the equal and not-equal matchers.

Which issue(s) this PR fixes:
Fixes #9111

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • CHANGELOG.md updated
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/upgrading/_index.md

@pull-request-size pull-request-size bot added size/S and removed size/L labels Apr 24, 2023
@jeschkies jeschkies force-pushed the karsten/regex-matcher-fix branch from d02052a to 8c88aa4 Compare April 24, 2023 11:24
@jeschkies jeschkies changed the title LogQL stream selector with escapes. Use un-escaped regexp literal for string matching. Apr 24, 2023
@grafanabot
Copy link
Collaborator

Hello @jeschkies!
Backport pull requests need to be either:

  • Pull requests which address bugs,
  • Urgent fixes which need product approval, in order to get merged,
  • Docs changes.

Please, if the current pull request addresses a bug fix, label it with the type/bug label.
If it already has the product approval, please add the product-approved label. For docs changes, please add the type/docs label.
If the pull request modifies CI behaviour, please add the type/ci label.
If none of the above applies, please consider removing the backport label and target the next major/minor release.
Thanks!

@jeschkies jeschkies force-pushed the karsten/regex-matcher-fix branch from 8c88aa4 to 25c8841 Compare April 24, 2023 11:31
@jeschkies jeschkies marked this pull request as ready for review April 24, 2023 11:31
@jeschkies jeschkies requested a review from a team as a code owner April 24, 2023 11:31
@jeschkies jeschkies force-pushed the karsten/regex-matcher-fix branch from 25c8841 to 1cabb7e Compare April 24, 2023 11:32
@jeschkies jeschkies force-pushed the karsten/regex-matcher-fix branch from 1cabb7e to 9e8a44c Compare April 24, 2023 11:58
Copy link
Contributor

@MasslessParticle MasslessParticle left a comment

Choose a reason for hiding this comment

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

Nice find!

@MasslessParticle MasslessParticle merged commit 7109c56 into grafana:main Apr 24, 2023
@grafanabot
Copy link
Collaborator

The backport to release-2.8.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new branch
git switch --create backport-9252-to-release-2.8.x origin/release-2.8.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x 7109c56bdccc7c90e3f1fcdb16c8a586b3a773c6
# Push it to GitHub
git push --set-upstream origin backport-9252-to-release-2.8.x
git switch main
# Remove the local backport branch
git branch -D backport-9252-to-release-2.8.x

Then, create a pull request where the base branch is release-2.8.x and the compare/head branch is backport-9252-to-release-2.8.x.

@jeschkies jeschkies deleted the karsten/regex-matcher-fix branch April 24, 2023 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LokiQL regex operator in stream selector together with escaping does not match label with two dots.
3 participants