How to use Loki Pattern Parser

In the official Loki Grafana documentation a pattern parser is mentioned:

However there are no additional resources on the parser online.
Is it still in development? If not from which version is it available?

I’m trying to extract a status code field from a log line similiar to the one in the documentation without using the regexp parser: - - [10/Jun/2021:09:14:29 +0000] "GET /api/plugins/versioncheck HTTP/1.1" 200 2 "-" "Go-http-client/2.0" "," "TLSv1.2" "US" ""

Hi @m3r1 good to know you are trying to use pattern parser!.

Yes, it’s not yet available in released version of Loki. But It’s available in main branch. You can build it if you want to use it. Or you can use any of the latest public docker images (e.g: main-8788ddb).

RE: how to use it! (from your example)
The LogQL query would be
| pattern "<ip> - - <_> \"<method> <uri> <_>\" <status> <size> <_> \"<agent>\" <_>"

I think the confusion was doc haven’t mentioned the syntax of using | pattern <pattern-string>. Hope this clear now!

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.