I am getting familiar with splunk commands, trying to extract hostname from an extracted field called monitor_name. monitor_name field data look like this,
[Linux][FWA Electronic Channel Messaging][l91oma1][Process][SS][/fiwlspoma4/was/INSTANCE1/profiles/base/servers/server1][error]
[Linux][Baseline][vlrtp569][Process][OSWatcher][SiSExclude]
[Linux][Baseline][vlrtp123][Process][srmclient][SiSExclude]
I would like to extract l91oma1, vlrtp569,vlrtp123 from the above field using rex command. Can someone help me with the regular expression.
use this
rex field=_raw "^(?:[^\[\n]*\[){3}(?P<fieldname>\w+)"
@kml_uvce your escaping backslashes were lost since you forgot to use the "code" tags around your regex. The regex should actually look like below:
rex field=_raw "^(?:[^\[\n]*[){3}(?P<fieldname>w+)"
And there is backslash missing before "w+" as well. So it should be
rex field=_raw "^(?:[^\[\n]*[){3}(?P<fieldname>\w+)"
Thanks everyone, that helped me.