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!

Casting Call: Compete in Cyber Games

Lights, Camera, SecOps: Apply to Compete in Cyber Games     Think you have what it takes to beat the clock? ...

Data Management Digest – June 2026

Welcome to the June 2026 edition of Data Management Digest! This month’s update is short and sweet, with a ...

Think Like an Architect: Introducing the Splunk Certified Cybersecurity Defense ...

In cybersecurity, defenders respond to threats. Architects design the systems that stop them.    As ...