I have a log stream from where I am extracting a set of fields to be set as either labels or metric values. The stream is not in a standard format so I am extracting the fields with regexp pipeline command, as below.
(...)
| regexp "(?P<api>\\w+)\\sAPI"
| regexp "\\[performed\\.(?P<action>\\w+)"
| regexp "duration\\s\\[(?P<duration_ms>\\d+)"
| regexp "response \\[(?P<response>.*?)\\]"
The problem is that the api
captured field, on some interaction, is not being populated, and I wanted to update those cases so that a default value was set - For presentation purposes.
I've tried using the native LogLQ's contains and hasPrefix template commands as the documentation suggests they can be used with if else
blocks. The documentation is not clear on how to build those blocks inside the label_format
or the line_format
pipeline commands. But depending on the approach it either returns a format error or does not do anything.
An working example would be appreciated. Thank you.
Note: Tried to tag this as a LogQL topic but not enough reputation to do so.