LogQL line_format padding

Hello,

is it possible to somehow add padding to the line_format processor?

line_format "{{.host}} {{.msg}}"

Can i pad {{.host}} to be for example 20 chars in length so that the messages would be aligned?

Best regards!

The line format uses Go’s text/template package. This supports padding. See template package - text/template - pkg.go.dev for more details and an example.

It’s not as simple as I thought. Maybe something like this can work:

| label_format full=“{{ repeat 3 _ }}{{ .job }}” | line_format “{{ .full | substr 2 -1 }}”

It creates a new label and adds an underscore at the beginning. Then a substring is extracted starting from the second character. An underscore was used here to make it easier to see.

Thanx, will try it out. Been looking into this go template thingy but couldn’t get it to work.

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