grafana / loki

Like Prometheus, but for logs.
https://grafana.com/loki
GNU Affero General Public License v3.0
23.83k stars 3.44k forks source link

LogQL line format: Add Entry variable to template #4248

Open riptl opened 3 years ago

riptl commented 3 years ago

Is your feature request related to a problem? Please describe.

The templates in line_format only have labels as inputs. They are missing the log entry. This makes it impossible to do string interpolation involving the log entry.

Describe the solution you'd like

Add the .Entry variable to line_format templates containing the log entry, like was done in https://github.com/grafana/loki/pull/2105 for promtail templates.

Describe alternatives you've considered none

Additional context none

nvtkaszpir commented 3 years ago

this can be now mitigated by extra query filter chains:

{namespace="my-namespace"} | regexp "(?P<msg>.*)" | line_format "{{.custom_label}} {{ .msg }}"

in short msg will match everything in message, but there should be nicer way to do it.

pgassmann commented 2 years ago

instead of the regex, the pattern matcher works too. | pattern "<MESSAGE>" | line_format "{{.custom_label}} {{ .MESSAGE }}"

jeschkies commented 2 years ago

@terorie would that suffice?