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

Complex PromQL expressions #4

Closed
ocervell opened this issue Apr 22, 2021 · 6 comments · Fixed by #5
Closed

Complex PromQL expressions #4

ocervell opened this issue Apr 22, 2021 · 6 comments · Fixed by #5
Labels
bug Something isn't working

Comments

@ocervell
Copy link

Hiyah,

does this packages support more complex PromQL expressions ?

I tried with one but the label set is not highlighted properly.

See the following for an example:
Screenshot 2021-04-22 at 18 27 31

@pabluk
Copy link
Owner

pabluk commented Apr 22, 2021

Hi @ocervell, it should also work with that kind of complex expressions.
In any case your expression seems to be a good test case, could you please paste a text version of it? I would like to included in the test suite and fix the output.

Thanks for report it 👍

@pabluk pabluk added enhancement New feature or request bug Something isn't working and removed enhancement New feature or request labels Apr 22, 2021
pabluk added a commit that referenced this issue Apr 22, 2021
pabluk added a commit that referenced this issue Apr 22, 2021
Labels were only dectected when using double quotes, now labels with
single quotes are detected as well.
@pabluk
Copy link
Owner

pabluk commented Apr 22, 2021

I confirm there's a bug, I was able see it using this fragment of your expression:

(sum(rate(metric_test_app{app="turtle",proc="web"}[2m])) by(node))

and I opened a pull request to fix it.

Here's an example of the output before:

test-nok

and after the fix from #5:

test-ok

note: those example were generated using

pygmentize -f png -O "line_numbers=False,style=monokai" -o example.png example.promql

I'll wait for your full text PromQL expression to test it before merging this fix.

@ocervell
Copy link
Author

Hi @pabluk,

Thanks for the swift response !

Here is the full expression:

(sum(rate(metric_test_app{app='turtle',proc='web',vendor=~'vendor.',status=~'(4|5)..'}[2m])) by(node)) or (sum(rate(metric_test_app{app='turtle',proc='web',vendor=~'vendor.'}[2m])) by(node)-sum(rate(metric_test_app{app='turtle',proc='web',vendor=~'vendor.',status!~'(4|5)..'}[2m])) by(node))/sum(rate(metric_test_app{app='turtle',proc='web',vendor=~'vendor.',status!~'(4|5)..'}[2m])) by(node)*100",

@pabluk
Copy link
Owner

pabluk commented Apr 23, 2021

Great! the output of the full expression looks better now
test4

by the way, your full expression allowed me to find out and fix a typo on a regexp.

I'll merge the PR and publish a new release asap.

Thanks again for helping out to improve this PromQL lexer!

@pabluk pabluk closed this as completed in #5 Apr 23, 2021
@pabluk
Copy link
Owner

pabluk commented Apr 23, 2021

The new release 0.0.6 is now available on PyPI https://pypi.org/project/pygments-promql/

@ocervell
Copy link
Author

Perfect ! Thanks a lot :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants