Highlighted
ciphercodes Valued Contributor.
Valued Contributor.
420 views

Flex Connector One Regex per line

Hi,
I would like to know if it is possible to have a one regex statement to match keys in a  log event per line ?
The order of keys in log events is not consistent and not all keys are present in all log messages. I know I can add optional regex match but there are too many variables and keys to deal with. The sample below is just an illustration for my question.

Sample:
id=123 staticvalue firstname="Foo" lastname="bar" age="22" location="Somwhere" pkey="123456"
id=124 staticvalue firstname="Blah" lastname="Whew" age="52" pkey="123456" location="Anywhere"
id=124 staticvalue firstname="Blah" pkey="123456" location="Anywhere" age="52"

I tried creating submessage id and restofmessage but I do not see the keys/values I am parsing.
id=(\d+) (staticvalue) (.*)
My submessage is anything between (*)
I now want to have multiple submessage patterns like:

submessage[0].pattern[0]
firstname="([^"]+)"
#assign key if exists

submessage[0].pattern[1]
lastname="([^"]+)"
#assign key if exists

submessage[0].pattern[2]
age="([^"]+)"
#assign key if exists

submessage[0].pattern[4]
location="([^"]+)"
#assign key if exists

submessage[0].pattern[5]
pkey="([^"]+)"
#assign key if exists

Is it possible to acheive regex match this way on a flex connector file ?

Thanks,

0 Likes
Reply
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.