Splunk Search

How to rex extract from text that starts with a newline and ends with a newline?

spencerneal
Explorer

Hello, 

I am trying to figure out how to rex extract from text that starts with a newline and ends with a newline.  For example:  \\nCAR PRODUCT: bat mobile\n

Does anyone know a good way around this situation so that only "bat mobile" is extracted?

 

Thank you for your help.

Spencer

Labels (1)
0 Karma

spencerneal
Explorer

Giuseppe,

Thank you for your help.

I am trying to rex extract "bat mobile" from something similar to the following raw text.

As you can see there is a newline following "bat mobile".  I am having trouble figuring out how to rex "bat mobile" only and not get everything after "bat mobile". 

example:  \\nDAMAGED PRODUCT: bat mobile\nmail:sneal@gmail.com

my current code is:  

|rex “DAMAGED PRODUCT:  (?P<SWN>.+?)"

However, I don't know what to put after the second parentheses so that rex will only extract "bat mobile".

I hope my thought makes sense.

Once again, thank you greatly for your help.

Spencer

 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @spencerneal,

as I said, the only way I can help you is that you share some samples (not one!) of your logs: eventually mask sensible contents but don't change the log structure.

Ciao.

Giuseppe

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @spencerneal,

the request is just a little vague because if in your events you have more lines, you'll have more extractions, is this what you want?

Otherwise please give more details in extraction and, please, share some sample of your data highlighting the parts to extract.

Ciao.

Giuseppe

0 Karma
Get Updates on the Splunk Community!

See just what you’ve been missing | Observability tracks at Splunk University

Looking to sharpen your observability skills so you can better understand how to collect and analyze data from ...

Weezer at .conf25? Say it ain’t so!

Hello Splunkers, The countdown to .conf25 is on-and we've just turned up the volume! We're thrilled to ...

How SC4S Makes Suricata Logs Ingestion Simple

Network security monitoring has become increasingly critical for organizations of all sizes. Splunk has ...