Splunk Search

Help with regex / replace needed

damucka
Builder

Hello,

I have the following event:

X Mon Mar  4 19:57:48:935 2019 X  *** WARNING => MMX 'EGPH5': mm_diagmode set 0 118: possible performance degradation #102400

WARNING could be also ERROR, I would like to handle both cases in one regex.

Now, I would like to:
1/ Skip the line beginning until the word WARNING / ERROR
2/ clear the event from all digits
3/ save the result into the "text"

For the digit clearing I have the following replace:

| eval text=replace(_raw,"\d{0}\d+","")

and it works fine. However I have issues with the skipping line until WARNING / ERROR. If I take the regex101, then the corresponding sed would be:

s/^(.*)\* //g

but when I apply it in the Splunk SPL it will do nothing:

| rex mode=sed "s/^(.*)\*//g"

.. not mentioning trying above in replace.

Could you please advice?
How would I skip the beginning of line and clear it from digits and assign to the text? Replace or sed, does not matter.

Kind Regards,
Kamil

Tags (1)
0 Karma
1 Solution

vnravikumar
Champion

Hi @damucka

Try like and please let me know sample output that you want

| makeresults 
| eval _raw="X Mon Mar  4 19:57:48:935 2019 X  *** WARNING => MMX 'EGPH5': mm_diagmode set 0 118: possible performance degradation #102400" 
| eval text=replace(_raw,"\d{0}\d+","")| rex field=text mode=sed "s/^(.*)\*//g"

View solution in original post

0 Karma

chrisyounger
SplunkTrust
SplunkTrust

What about this:

|makeresults | eval _raw = "X Mon Mar 4 19:57:48:935 2019 X *** WARNING => MMX 'EGPH5': mm_diagmode set 0 118: possible performance degradation #102400" | rex mode=sed field=_raw "s/\d+//" |rex mode=sed "s/^(.*?)\*+//g"

0 Karma

vnravikumar
Champion

Hi @damucka

Try like and please let me know sample output that you want

| makeresults 
| eval _raw="X Mon Mar  4 19:57:48:935 2019 X  *** WARNING => MMX 'EGPH5': mm_diagmode set 0 118: possible performance degradation #102400" 
| eval text=replace(_raw,"\d{0}\d+","")| rex field=text mode=sed "s/^(.*)\*//g"
0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...