butschster / prometheus-parser

Prometheus data parser to AST written on PHP8
MIT License
10 stars 2 forks source link

Unable to parse output from the latest version of prometheus #1

Open jakubstephan opened 1 year ago

jakubstephan commented 1 year ago

HI.

I have a output taken by CURL from the server (by debug i've saved into a file)

prometheus.txt

I'm trying to parse it in that way using Laravel:

        $this->parser = ParserFactory::create();
// ...
        $content = Storage::disk('local')->get('prometheus');
        $schema = $this->parser->parse(<<<SCHEMA
$content
SCHEMA
        );
        $metrics = $schema->getMetrics(); // array of Metric

But i'm getting an exception:

Phplrt
 \ 
Parser
 \ 
Exception
 \ 
UnrecognizedTokenException
PHP 8.2.8
10.22.0
Syntax error, unrecognized "'" 147. | # HELP prometheus_build_info A metric with a constant '1' value labeled by version, revision, branch, goversion from which prometheus was built, and the goos and goarch for the build. | ^
butschster commented 1 year ago

Hello @jakubstephan!

Could you provide a content?

jakubstephan commented 1 year ago

@butschster it's attached as a file to the original post.

LaravelFreelancerNL commented 1 month ago

I seem to be running in to the same problem. I've toyed around with it a bit, but unfortunately don't have the time to dig deeper. With this comment is a metric file from ArangoDB's documentation. This will will trigger a lot of errors.

It seems like the problem lies with the acceptable characters in the different regexes as well as detection which regex needs to be used where.

arangodb-metrics.txt