5

In LogQL line_format template expression, is there a way to access the original log entry (assume the entry is not in JSON or any parseable format and all labels are log labels and not extracted labels).

example: ... | line_format "{{.log_label1}}, {{.log_label2}}: {{<some way to show the entire original log entry>}}"

JNev
  • 53
  • 1
  • 3

3 Answers3

7

One way it to prepend it with a regular expression capturing the entire message

... |regexp '(?P<message>.*)' |line_format "{{.some_other_var}} {{.message}}"

Note that the ' around the regex should really by ` otherwise it might not work

mgoetzke
  • 804
  • 7
  • 14
  • The regexp is a nice trick, thanks! I wonder if there is some "default" variable that would allow the same without involving another parser... – JNev Mar 26 '21 at 17:14
  • Yup, I was wondering that too and then found your question :) sadly the documentation is not really that good , though it is a great product – mgoetzke Mar 27 '21 at 18:22
3

You can use the line template function:

... | line_format "{{.host}} {{ __line__ }}"
Jan Garaj
  • 25,598
  • 3
  • 38
  • 59
japi
  • 31
  • 1
0

It looks like instead of regexp you can use json parser:

... | json | line_format "{{.stream}}: {{.log}}"
mrk
  • 284
  • 3
  • 5