Splunk Search

Regex expression to extract fields

cgbsplunk
Explorer

I have two fields below that show up in our log files.  I used Splunk tool to create the Regex to extract the fields and at first I thought it worked until we had fields with different values that didn't extract.  Is there a simple Regex I can use to extract ObjectType and Domain Controller fields in example below?  Values should never have space so we can end value after first space.

ObjectType User

Domain Controller TSTETCDRS001

Labels (2)
0 Karma
1 Solution

PickleRick
SplunkTrust
SplunkTrust

And simple

Object\s+Type\s+(?<Object Type>\w+)

Doesn't work?

Same for the other one

Domain\s+Controller\s+(?<Domain Controller>\w+)

Check your regexes on https://regex101.com

View solution in original post

0 Karma

PickleRick
SplunkTrust
SplunkTrust

And simple

Object\s+Type\s+(?<Object Type>\w+)

Doesn't work?

Same for the other one

Domain\s+Controller\s+(?<Domain Controller>\w+)

Check your regexes on https://regex101.com

0 Karma

cgbsplunk
Explorer

Really appreciate the help.  That worked for those 2.  I also need one for Target.  I tried this:

Target\s+(?<Target>\w+)

But with a value of this:

Target ABCDE\test.user

I only get the ABCDE.  How do I change the expression to get the entire ABCDE\test.user

 

0 Karma

cgbsplunk
Explorer

I was able to get this to work by changing w to S like this:

Target\s+(?<Target>\S+)

Thanks again for the help

 

0 Karma

PickleRick
SplunkTrust
SplunkTrust

Show us a sample of your full events.

0 Karma

cgbsplunk
Explorer

These are coming from windows event logs.  Some of the fields are in name value pairs and extract on their own but last 4 fields are the ones I need expressions for.  Here is example of entire message:

10/27/2021 02:39:17 PM
LogName=Application
EventCode=16117
EventType=0
ComputerName=XXXXXXXXX002.xxxx.com
User=NOT_TRANSLATED
Sid=S-1-5-21-114000000-41296648-3127784425-637889
SidType=0
SourceName=AdminSvc
Type=Information
RecordNumber=1502524
Keywords=Audit Success, Classic
TaskCategory=SetInfo
OpCode=None
Message=Action SetInfo
ObjectType Computer
AssistantAdmin xxxx\xxxxx
Target xxxxx\xxxx-xxxx$
Domain Controller xxxxxx06
AccountDisabled

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...