Search code examples
grafana-loki

Get original entry value in LogQL line_format


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>}}"


Solution

  • 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