I am new to Loki and am trying to ingest some web servers logs that are formatted in W3C Extended Log File format. My particular instance is tab-delimited. Here is an example of a log line:
192.168.0.20 2022-01-26 16:19:36 GET /wls-exporter/metrics 200 0.003
Unfortunately, I am unable to add keys to this data, so Loki is unable to parse out the fields automatically with logfmt. I read about the Pattern parser in the documentation, but it doesn’t seem to work to get individual values out of my entries. Here’s the patterns I’ve tried so far:
This will leave the newline on the end of the last field however, so that needs to be stripped using label_format if you want to use that value in a metric query:
Also it appears that you can’t use the “-” character in a field name using the pattern parser. When I switched to using “_” in the field names was when I started to get results. Not sure if that’s something I was doing wrong in the query or if that’s expected behavior, but something to keep in mind.