I am trying to add an additional "field" to the fluent-bit cri parser, however my regex never works.
This is the original working regex: ^(?<time>[^ ]+) (?<stream>stdout|stderr) (?<logtag>[^ ]*) (?<message>.*)$
As it seems this looks sequentially through the log for the various elements. I now want to also add a "field" called level, like this: <level>, which is the log level and should be any of INFO, WARNING and ERROR. The level will occur anywhere within the message.
As an example: https://rubular.com/r/j6KxU3LrE3jjcA
Has anybody got an idea how I can add it?
Looks like your system is using Onigmo Regex in Ruby mode based on it's documentation.
EXAMPLE
I think this pattern should work nicely for you:
Based on your example you might use below without flags and delimiters:
I have tested the above regex pattern in Ruby and below are the results with the sample test set. It will match in any order and making sure it is valid. In PCRE you will not get a group if not matched, but in Ruby you will get a nil value for the group if there is no match.