Splunk Search

How to write a Rex query that will ignore some characters and then extract the message?

Splunk235
Engager

I have error logs like the below. How can I write a Rex query to match both the logs and only extract the message after the first colon (:)? Thanks.

 

Sample Log lines:

Script exception for job id 'ABc12345' : Too many rows: 500.

Script exception for job id 'XyZ78943' : Too many DMLs: 20.

 

Results should be:

Too many rows: 500.

Too many DMLs: 20.

Labels (3)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @Splunk235,

please try this regex:

| rex "Script exception for job id \'\w*\d*\' : (?<message>[^\.]*)"

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

Ciao.

Giuseppe

View solution in original post

0 Karma

Thulasinathan_M
Contributor

Hi,
Here is the try anywhere query for your requirement.

 

| makeresults 
| eval _raw="Script exception for job id 'ABc12345' : Too many rows: 500."
| rex field=_raw ": (?<Extracted>.*)"

 

 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Splunk235,

please try this regex:

| rex "Script exception for job id \'\w*\d*\' : (?<message>[^\.]*)"

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

Ciao.

Giuseppe

0 Karma

Splunk235
Engager

Is there a way to embed the same into this query?

rex field=logLine "(Error Occurred During Script|UnhandledException ->)(\s|\S)(?<errorMessage>.*)"

 

This didn't work, but something like this?

rex field=logLine "(Error Occurred During Script|for job id \'\w*\d*\' :|UnhandledException ->)(\s|\S)(?<errorMessage>.*)"

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Splunk235 ,

good for you, see next time!

Ciao and happy splunking

Giuseppe

P.S.: Karma Points are appreciated by all the contributors 😉

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Splunk235 ,

yes, you can test your regex and it runs.

let us know if we can help you more, or, please, accept one answer for the other people of Community.

Ciao and happy splunking

Giuseppe

P.S.: Karma Points are appreciated by all the contributors 😉

0 Karma
Get Updates on the Splunk Community!

See your relevant APM services, dashboards, and alerts in one place with the updated ...

As a Splunk Observability user, you have a lot of data you have to manage, prioritize, and troubleshoot on a ...

Index This | What goes away as soon as you talk about it?

May 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this month’s ...

What's New in Splunk Observability Cloud and Splunk AppDynamics - May 2025

This month, we’re delivering several new innovations in Splunk Observability Cloud and Splunk AppDynamics ...