Splunk Search

Can you help me write a regular expression

rashi83
Path Finder

Need to extract Insurer , User , Dealer name

2019-11-01 06:54:20 W3SVC4 AUSYD11AS90 172.29.5.28 GET /Areas/Framework/Content/Style/fonts/open-sans-v10-latin-regular.woff2 - 80 - 172.29.0.250 HTTP/1.1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64;+rv:60.0)+Gecko/20100101+Firefox/60.0 AUTOMOTIVE_LastLoginId=MS3352919;+External_UserType=USER1;+External_ID=tEST1;+First_level_Hierarchy=TEST2;+Second_level_Hierarchy=tEST;+Account_Type=DBA;+Dealer_Outlet_Name=;+Title=;+Insurer=ABC;+encryptedcookie=470097324.20480.0000;

Tags (1)
0 Karma
1 Solution

mayurr98
Super Champion

Try this :

| makeresults 
| eval _raw="2019-11-01 06:54:20 W3SVC4 AUSYD11AS90 172.29.5.28 GET /Areas/Framework/Content/Style/fonts/open-sans-v10-latin-regular.woff2 - 80 - 172.29.0.250 HTTP/1.1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64;+rv:60.0)+Gecko/20100101+Firefox/60.0 AUTOMOTIVE_LastLoginId=MS3352919;+External_UserType=USER1;+External_ID=tEST1;+First_level_Hierarchy=TEST2;+Second_level_Hierarchy=tEST;+Account_Type=DBA;+Dealer_Outlet_Name=;+Title=;+Insurer=ABC;+encryptedcookie=470097324.20480.0000;" 
| rex "Account_Type=(?<Account_Type>[^\(;\+)]+)" 
| rex "Insurer=(?<Insurer>[^\(;\+)]+)" 
| rex "Dealer_Outlet_Name=(?<Dealer_Outlet_Name>[^\(;\+)]+)" 

in your environment you should try:

 index=<your_index>| rex "Account_Type=(?<Account_Type>[^\(;\+)]+)" 
 | rex "Insurer=(?<Insurer>[^\(;\+)]+)" 
 | rex "Dealer_Outlet_Name=(?<Dealer_Outlet_Name>[^\(;\+)]+)" 

View solution in original post

to4kawa
Ultra Champion
| stats count
| eval _raw="2019-11-01 06:54:20 W3SVC4 AUSYD11AS90 172.29.5.28 GET /Areas/Framework/Content/Style/fonts/open-sans-v10-latin-regular.woff2 - 80 - 172.29.0.250 HTTP/1.1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64;+rv:60.0)+Gecko/20100101+Firefox/60.0 AUTOMOTIVE_LastLoginId=MS3352919;+External_UserType=USER1;+External_ID=tEST1;+First_level_Hierarchy=TEST2;+Second_level_Hierarchy=tEST;+Account_Type=DBA;+Dealer_Outlet_Name=;+Title=;+Insurer=ABC;+encryptedcookie=470097324.20480.0000;"
| kv

Hi,
Insuer:
User:
Dealer name:
What is the value for this log?

0 Karma

mayurr98
Super Champion

Try this :

| makeresults 
| eval _raw="2019-11-01 06:54:20 W3SVC4 AUSYD11AS90 172.29.5.28 GET /Areas/Framework/Content/Style/fonts/open-sans-v10-latin-regular.woff2 - 80 - 172.29.0.250 HTTP/1.1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64;+rv:60.0)+Gecko/20100101+Firefox/60.0 AUTOMOTIVE_LastLoginId=MS3352919;+External_UserType=USER1;+External_ID=tEST1;+First_level_Hierarchy=TEST2;+Second_level_Hierarchy=tEST;+Account_Type=DBA;+Dealer_Outlet_Name=;+Title=;+Insurer=ABC;+encryptedcookie=470097324.20480.0000;" 
| rex "Account_Type=(?<Account_Type>[^\(;\+)]+)" 
| rex "Insurer=(?<Insurer>[^\(;\+)]+)" 
| rex "Dealer_Outlet_Name=(?<Dealer_Outlet_Name>[^\(;\+)]+)" 

in your environment you should try:

 index=<your_index>| rex "Account_Type=(?<Account_Type>[^\(;\+)]+)" 
 | rex "Insurer=(?<Insurer>[^\(;\+)]+)" 
 | rex "Dealer_Outlet_Name=(?<Dealer_Outlet_Name>[^\(;\+)]+)" 

rashi83
Path Finder

Thanks, it worked

0 Karma

rmmiller
Contributor

When you say "User", do you actually mean "External_ID" or some other named field?
Technically speaking, your example contains a user field with a value of "-".

The same clarification applies for "Dealer name" -- do you actually mean "Dealer_Outlet_Name"?

0 Karma

rashi83
Path Finder

I am interested in extracting these fields -
+Insurer
+Dealer_Outlet_Name
+Account_Type

Since some times sequence of these fields can be changes, I want regular expression which contains the field name too like "hostname:(?P[^,]+)[^\n]"

How do I do for the above fields

0 Karma

harsmarvania57
Ultra Champion

Can you please provide expected output for each field ?

0 Karma

rashi83
Path Finder

For example Insurer field = ABC
Account_Type = DBA

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...