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

Fix Prometheus regex parsing #9153

Merged
merged 1 commit into from
Jan 2, 2018
Merged

Fix Prometheus regex parsing #9153

merged 1 commit into from
Jan 2, 2018

Conversation

e-dard
Copy link
Contributor

@e-dard e-dard commented Nov 24, 2017

Required for all non-trivial PRs
  • Rebased/mergable
  • Tests pass

Fixes #9134.

InfluxDB expects regex condition values to be influxql.RegexLiterals, which have literals beginning and ending in forward slashes.

Also adds further test coverage to ReadRequestToInfluxQLQuery.

Only thing that might be worth checking is whether the regex values originating from Prometheus format have already escaped forward slashes or not. For example, will the following condition arrive as:

region =~ foo/bar which we would then convert into region =~ /foo\/bar/

or, would the condition arrive as region =~ foo\/bar, which we would then incorrectly convert to region =~ /foo\\/bar/?

No CHANGELOG update as this will probably be back-ported.

Copy link
Contributor

@jsternberg jsternberg left a comment

Choose a reason for hiding this comment

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

The requested changes are really minor so I'm pre-approving with those being changed.

@@ -93,6 +94,8 @@ func ReadRequestToInfluxQLQuery(req *remote.ReadRequest, db, rp string) (*influx
// condFromMatcher converts a Prometheus LabelMatcher into an equivalent InfluxQL BinaryExpr
func condFromMatcher(m *remote.LabelMatcher) (*influxql.BinaryExpr, error) {
var op influxql.Token
var RHS influxql.Expr
Copy link
Contributor

Choose a reason for hiding this comment

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

Can RHS be lowercase? Since it's a local variable, I think that's the standard for local variables.

"testing"

"github.com/influxdata/influxql"

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you remove the space between these?

This converts Prometheus' regex syntax for a condition value into InfluxDB's.
@ghost ghost assigned e-dard Nov 27, 2017
@ghost ghost added the review label Nov 27, 2017
@e-dard e-dard merged commit 1f3352e into master Jan 2, 2018
@ghost ghost removed the review label Jan 2, 2018
@e-dard e-dard mentioned this pull request Jan 3, 2018
3 tasks
@e-dard e-dard deleted the er-prom-parsing branch January 15, 2018 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants