Splunk Search

How to display only a substring of result set?

HelloItsMe76
Explorer

When i search for the string "ERROR"  in a log i get the below 

<

DEBUG : blah blah

INFO : blah blah blah 

ERROR : <some error string> 

More blah blah

>

 

I want to only show the whole line that starts with ERROR.  The length of the error line is variable.

How can i do this?

I do understand that fixing the line breaks formatting in prop.conf might be a quicker way but i dont have access to that file so would like to do it in the result head.  thanks in advance.  

Labels (1)
0 Karma
1 Solution

scelikok
SplunkTrust
SplunkTrust

Hi @HelloItsMe76,

You can use regex to extract the error string using below command after your search This will create a new field error_string that contains ERROR line info.

| rex field=_raw "ERROR\s+:\s+(?<error_string>.+)"

 

If this reply helps you an upvote and "Accept as Solution" is appreciated.

View solution in original post

scelikok
SplunkTrust
SplunkTrust

Hi @HelloItsMe76,

You can use regex to extract the error string using below command after your search This will create a new field error_string that contains ERROR line info.

| rex field=_raw "ERROR\s+:\s+(?<error_string>.+)"

 

If this reply helps you an upvote and "Accept as Solution" is appreciated.

HelloItsMe76
Explorer

thanks, that worked. 

0 Karma
Get Updates on the Splunk Community!

Splunk Up Your Game: Why It's Time to Embrace Python 3.9+ and OpenSSL 3.0

Did you know that for Splunk Enterprise 9.4, Python 3.9 is the default interpreter? This shift is not just a ...

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 ...

Cultivate Your Career Growth with Fresh Splunk Training

Growth doesn’t just happen—it’s nurtured. Like tending a garden, developing your Splunk skills takes the right ...