Splunk Search

How to write regex to extract value in between two phrases?

syazwani
Path Finder

Hi, I need help to extract a value from field named "message".

Field "message" value is as below:

The process C:\Windows\system32\winlogon.exe (PRD01) has initiated the power off of computer PC01 on behalf of user ADMIN JABATAN for the following reason: No title for this reason could be found

The process C:\Windows\system32\shutdown.exe (PRD01) has initiated the restart of computer PC01 on behalf of user ADMIN\SUPPORT for the following reason: No title for this reason could be found

The process C:\Windows\system32\shutdown.exe (PRD01) has initiated the restart of computer PC01 on behalf of user admin for the following reason: No title for this reason could be found

The value i want to extract is:

newField
ADMIN JABATAN
ADMIN\SUPPORT
admin

 

Please assist. Thanks.

Labels (3)
0 Karma
1 Solution

batabay
Path Finder

Hi,

 

your search 

| rex field=message "of\suser\s(?<new_user>.+?)\sfor\sthe"

this command extract new_user field.

View solution in original post

syazwani
Path Finder

Hi @batabay, thank you for the response. It works!

0 Karma

batabay
Path Finder

Hi,

 

your search 

| rex field=message "of\suser\s(?<new_user>.+?)\sfor\sthe"

this command extract new_user field.

Get Updates on the Splunk Community!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI! Discover how Splunk’s agentic AI ...

[Puzzles] Solve, Learn, Repeat: Dereferencing XML to Fixed-length events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Stay Connected: Your Guide to December Tech Talks, Office Hours, and Webinars!

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...