All Apps and Add-ons

How to use the extracted field expressions using rex command ?

Real_captain
Path Finder

HI 

Can someone please let me know how I can use the below expression (generated via Field Extraction) directly via Rex command: 

Regular expression generated via Field extraction:

 

^(?:[^,\n]*,){7}\s+"\w+_\w+_\w+_\w+_\w+":\s+"(?P<POH>[^"]+)

 

Real_captain_1-1728224376355.png

Real_captain_0-1728224337078.png

I am using the rex command as below but i am getting an error : 

 

| rex field=Message mode=sed "(?:[^,\n]*,){7}\s+"\w+_\w+_\w+_\w+_\w+":\s+"(?P<POH1>[^"]+)"

 

Labels (1)
0 Karma

inventsekar
SplunkTrust
SplunkTrust

Hi @Real_captain , the mode=sed was not from the field extraction wizard. may i know why you thought to use the mode=sed, pls suggest. 


As you can see, 

Syntax: mode=sed Description: Specify to indicate that you are using a sed (UNIX stream editor) expression. sed-expression Syntax: "<string>" Description: When mode=sed, specify whether to replace strings (s) or substitute characters (y) in the matching regular expression. 

https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Rex#Syntax


not sure, but lets try:

 

| rex field=Message "(?:[^,\n]*,){7}\s+"\w+_\w+_\w+_\w+_\w+":\s+"(?P<POH1>[^"]+)"

 

 

Sample log lines will be helpful to troubleshoot this, thanks.  

thanks and best regards,
Sekar

PS - If this or any post helped you in any way, pls consider upvoting, thanks for reading !
0 Karma
Get Updates on the Splunk Community!

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...