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

Matching escaped double quotes #2974

Closed
iobestar opened this Issue Jul 20, 2017 · 6 comments

Comments

Projects
None yet
4 participants
@iobestar
Copy link

iobestar commented Jul 20, 2017

What did you do?
PromQL: metric_foo_bar{name="\"bar\""}

What did you expect to see?
Data endpoints for metric metric_foo_bar with where label 'name' have value '"bar"'

What did you see instead? Under which circumstances?
No data endpoints.

  • Prometheus version:
    prometheus, version 2.0.0-beta.0 (branch: master, revision: 2b5d915)
    build user: root@fc24486243df
    build date: 20170712-12:24:53
    go version: go1.8.3

This query works on Prometheus 1.7.1 but on Prometheus 2.0 I had to replace it with regex matcher:
metric_foo_bar{name=~".+bar.+"}

@gouthamve

This comment has been minimized.

Copy link
Member

gouthamve commented Jul 20, 2017

@iobestar Can you try: metric_foo_bar{name="\"bar\""} ?

In any case, @brian-brazil WDYT?

@gouthamve gouthamve added the dev-2.0 label Jul 20, 2017

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Jul 20, 2017

That query does not work on 1.x, it should be escaped as you suggest.

@iobestar

This comment has been minimized.

Copy link
Author

iobestar commented Jul 20, 2017

Correction of my initial post I am using escaped double quotes (escape disappear in presentation):
PromQL: metric_foo_bar{name="\"bar\""}

Escaped double quotes works on Prometheus 1.x but it doesn't work on Prometheus 2.0

@gouthamve gouthamve self-assigned this Jul 21, 2017

@juliusv

This comment has been minimized.

Copy link
Member

juliusv commented Jul 24, 2017

Confirmed, this is a bug in the new text protocol parser, which just extracts slices of the underlying input bytes into label values verbatim, without doing any interpretation of escape sequences \n, \", or \\. So it stores the wrong label value, and then of course it can't be selected.

Problematic place in the code: https://github.com/prometheus/prometheus/blob/dev-2.0/pkg/textparse/parse.go#L108-L132

gouthamve added a commit to gouthamve/prometheus that referenced this issue Jul 26, 2017

Handle common escape characters properly.
Fixes prometheus#2974

Signed-off-by: Goutham Veeramachaneni <cs14btech11014@iith.ac.in>

gouthamve added a commit to gouthamve/prometheus that referenced this issue Jul 27, 2017

Handle common escape characters properly.
Fixes prometheus#2974

Signed-off-by: Goutham Veeramachaneni <cs14btech11014@iith.ac.in>

juliusv added a commit that referenced this issue Jul 27, 2017

Handle common escape characters properly. (#2995)
Fixes #2974

Signed-off-by: Goutham Veeramachaneni <cs14btech11014@iith.ac.in>
@gouthamve

This comment has been minimized.

Copy link
Member

gouthamve commented Aug 1, 2017

Fixed in #2995

@gouthamve gouthamve closed this Aug 1, 2017

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 23, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 23, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.