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

`promql.parseSeriesDesc` does not parse negative values #4356

Closed
kevinjqiu opened this Issue Jul 6, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@kevinjqiu
Copy link

kevinjqiu commented Jul 6, 2018

Bug Report

What did you do?

I'm building a tool that piggy-backs on the promql's testing facility to allow custom test cases for alert rules to be generated from a user defined yaml file.

However, it appears that promql.parseSeriesDesc function does not parse negative values correctly, e.g.,

parseSeriesDesc("my_metric{a=\"b\"} 1 -1") - I expect to see the parsed values to be [1, -1], however, it throws a parser error:

could not parse: parse error at char 22: unexpected end of input in series values, expected "x"

If the negative value appears first in the list, the series can be correctly parsed:

parseSeriesDesc("my_metric{a=\"b\"} -1 1) <- this parses correctly.

I have written a test case that demonstrated this parser error, and here's the test output:

=== RUN   TestParseSeries
--- FAIL: TestParseSeries (0.00s)
	parse_test.go:1778: error in input: 
		
		my_metric{a="b"} 1 -1
	parse_test.go:1779: could not parse: parse error at char 22: unexpected end of input in series values, expected "x"
FAIL

EDIT: Add link to the test code that demonstrate this bug

@codesome

This comment has been minimized.

Copy link
Member

codesome commented Aug 30, 2018

Adding to above description, this happens not only for -, but also for +. '1 +1' would also error out.

Basically for - or +, the parser is expecting notation like 1 -1x3, 1 +1x4 (except for the first number).

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 22, 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 22, 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.