Splunk Search

Regex: subpattern name expected

robprice797
New Member
org_name="myOrg" index="myIndex" app_name="myAppName" space_name="Staging"
| rex field=msg "stack:(?<.*java\.lang.*Exception.*>\S+) "
| eval earliest=_time-1
| eval latest=_time+1
| cluster t=0.9 showcount=t 
| head 20 
| spath msg
| table timestamp,_time,stack,msg 
| sort -timestamp
| reverse

I get the error:

Error in 'rex' command: Encountered the following error while compiling the regex 'stack:(?<.*java\.lang.*Exception.*>\S+) ': Regex: subpattern name expected

Can someone help?

Tags (2)
0 Karma

woodcock
Esteemed Legend

Try this:

index="myIndex" org_name="myOrg" app_name="myAppName" space_name="Staging"
| rex field=msg "(?<stack>.*java\.lang.*Exception.*\S+)"
| eval earliest=_time-1
| eval latest=_time+1
| cluster t=0.9 showcount=t 
| head 20 
| spath msg
| table timestamp,_time,stack,msg 
| sort -timestamp
| reverse

I am assuming that you are trying to create a field called stack but I have no idea what the rest of the RegEx should be. If this is not correct, expand on this:
https://regex101.com/r/HdGXie/1

0 Karma

chrisyounger
SplunkTrust
SplunkTrust

Try this:

org_name="myOrg" index="myIndex" app_name="myAppName" space_name="Staging"
| rex field=msg "(?<stack>java.lang.Exception.\S+)"
| eval earliest=_time-1
| eval latest=_time+1
| cluster t=0.9 showcount=t 
| head 20 
| spath msg
| table timestamp,_time,stack,msg 
| sort -timestamp
| reverse
0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...