Possible to use slices in Promtail pipline_stages templates?

I am trying to modify a string using Promtail’s template pipeline stage.
I specifically need to re-format a date so it will be recognised as such by Loki. This involves injecting a few dashes, colons etc at specific locations in the string read from the log file.

I get that I can use string functions in templates, e.g. {{ len .myString }} will give me the length of myString. Nice.

But I’d like to separate the first 4 digits, inject a dash, add digit 5-6, inject a dash etc.
Can’t get the slicing to work though. Is it even supported in Promtail templates?

Have tried things like:

  • regex: <do parsing here, resulting in myString field>
  • template:
    source: myString_new
    template: ‘{{ .myString[0:3] }}’

The slicing above fails with an error:
“failed to make file target manager: invalid template stage config: template: pipeline_template:1: unexpected bad character U+005B ‘[’ in command”

Do I use the wrong syntax, or am I trying something that is not possible (i.e. slicing not being supported)?