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!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...