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

Unable to parse lines with URLs inside #2

Open
gendergap opened this issue Jan 27, 2024 · 3 comments
Open

Unable to parse lines with URLs inside #2

gendergap opened this issue Jan 27, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@gendergap
Copy link

gendergap commented Jan 27, 2024

I encounter an error when parsing lines like this:

use Butschster\Prometheus\ParserFactory;

$parser = ParserFactory::create();

$schema = $parser->parse(<<<SCHEMA
some_metric{host="9323832a174b",agent_url="http://container:8080/path",name="CoolMetric"} 3
SCHEMA);

The error message is this:

Phplrt\Parser\Exception\UnrecognizedTokenException: Syntax error, unrecognized "\""
   1. | some_metric{host="9323832a174b",agent_url="http://container:8080/path",name="CoolMetric"} 3
      |                                           ^

Is there something I can do or is this a bug in the software?

@butschster butschster self-assigned this Jan 28, 2024
@butschster butschster added the bug Something isn't working label Jan 28, 2024
@gendergap
Copy link
Author

gendergap commented Jan 29, 2024

Update: I had introduced a typo when I sanitized my demo output. I have just fixed the issue description, but unfortunately the problem is still real.

@gendergap
Copy link
Author

Neither in the grammar.php nor in the EBNF file (which seems to be used for testing) can I find any reference to forward slashed being allowed in the quoted value of the labels. Could this be the issue? Would it be safe to add the slash as a new allowed character or is there some complicated schema behind that needs to be respected?

@gendergap
Copy link
Author

Hello @butschster

I played around a bit with the expressions in the Grammar and found a cascade of new problems with the file I need to parse. Not sure how to progress here. If it would only have been one additional char, I'd have prepared a pull request. But with so many differences, I'm kind of doubtful if my file (generated by Telegraf with a Prometheus output plugin) is in any way following a standard. Do you happen to know which schema definition you followed when you created the parser? Perhaps I can see if there should actually be more different variants allowed (which I would gladly contribute) or if I'm better off with a fork that accommodates my weird file.

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

No branches or pull requests

2 participants