Splunk Search

How to accomodate or condition in regex

ghostrider
Path Finder

I have 2 types of error messages that I want to display along with their count. One error has "." at the end and another has "." at the end but has some redundant string surrounded by "<>" which I dont need. Is there a way to accomodate both these in the same regex? Currently I am using below regex with only "." condition and it seems its not working for messages with "<"

Message 1 : 

 

stack_trace : com.abc.xyz.package.ExceptionName: Missing A.

 

 

Message 2: 

 

 

stack_trace : com.abc.xyz.package.ExceptionName: Missing B <abcd> com.

 

 

Query

 

BASE_SEARCH| rex field=_raw "Exception: (?<ExceptionText>[^\.]+)"
| stats count as Count by "ExceptionTest"

 

 

Expected Output

 

Missing A           3

Missing B           4

 

Actual Output

 

Missing A                      3

Missing B <abcd> com           4

 

 

0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @ghostrider,

please try this regex

ExceptionName:\s+(?<message>[^\.\<]+)

that you can test at https://regex101.com/r/Qegzo3/1

Ciao.

Giuseppe

View solution in original post

gcusello
SplunkTrust
SplunkTrust

Hi @ghostrider,

please try this regex

ExceptionName:\s+(?<message>[^\.\<]+)

that you can test at https://regex101.com/r/Qegzo3/1

Ciao.

Giuseppe

GaetanVP
Contributor

Hello @ghostrider ,

You could try this : 

 

BASE_SEARCH
| rex field=_raw "ExceptionName: (?<ExceptionText>[^\.\<]+)"
| stats count as Count by "ExceptionText"

 

Hope it helps!

Regards,
GaetanVP

Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...